How to use the stellar-base.encodeBase58Check function in stellar-base

To help you get started, we’ve selected a few stellar-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stellar / js-stellar-sdk / src / transaction.js View on Github external
constructor(envelope) {
        if (typeof envelope === "string") {
            let buffer = new Buffer(envelope, "hex");
            envelope = xdr.TransactionEnvelope.fromXdr(buffer);
        }
        // since this transaction is immutable, save the tx
        this.tx = envelope._attributes.tx;
        this.source = encodeBase58Check("accountId", envelope._attributes.tx._attributes.sourceAccount);
        this.fee = envelope._attributes.tx._attributes.fee;
        this.sequence = envelope._attributes.tx._attributes.seqNum.toString();
        this.minLedger = envelope._attributes.tx._attributes.minLedger;
        this.maxLedger = envelope._attributes.tx._attributes.maxLedger;
        let operations = envelope._attributes.tx._attributes.operations;
        this.operations = [];
        for (let i = 0; i < operations.length; i++) {
            this.operations[i] = Operation.operationToObject(operations[i]._attributes);
        }
        let signatures = envelope._attributes.signatures;
        this.signatures = [];
        for (let i = 0; i < signatures.length; i++) {
            this.signatures[i] = signatures[i];
        }
    }
github stellar / js-stellar-sdk / src / currency.js View on Github external
static fromOperation(xdr) {
        if (xdr._switch.name == "currencyTypeNative") {
            return this.native();
        } else {
            let code = xdr._value._attributes.currencyCode;
            let issuer = encodeBase58Check("accountId", xdr._value._attributes.issuer);
            return new this(code, issuer);
        }
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
}
                if (attrs.homeDomain) {
                    obj.homeDomain = attrs.homeDomain;
                }
                break;
            case "createOffer":
                obj.type = "createOffer";
                obj.takerGets = Currency.fromOperation(attrs.takerGets);
                obj.takerPays = Currency.fromOperation(attrs.takerPays);
                obj.amount = attrs.amount.toString();
                obj.price = attrs.price._attributes.n / attrs.price._attributes.d;
                obj.offerId = attrs.offerId.toString();
                break;
            case "accountMerge":
                obj.type = "accountMerge";
                obj.destination = encodeBase58Check("accountId", operation.body._value);
                break;
            case "inflation":
                obj.type = "inflation";
                break;
            default:
                throw new Error("Unknown operation");
        }
        return obj;
    }
}
github stellar / js-stellar-sdk / src / operation.js View on Github external
obj.clearFlags = attrs.clearFlags;
                }
                if (attrs.setFlags) {
                    obj.setFlags = attrs.setFlags;
                }
                if (attrs.thresholds) {
                    obj.thresholds = {
                        weight: Number(attrs.thresholds[0]),
                        low: Number(attrs.thresholds[1]),
                        medium: Number(attrs.thresholds[2]),
                        high: Number(attrs.thresholds[3]),
                    };
                }
                if (attrs.signer) {
                    let signer = {};
                    signer.address = encodeBase58Check("accountId", attrs.signer._attributes.pubKey);
                    signer.weight = attrs.signer._attributes.weight;
                    obj.signer = signer;
                }
                if (attrs.homeDomain) {
                    obj.homeDomain = attrs.homeDomain;
                }
                break;
            case "createOffer":
                obj.type = "createOffer";
                obj.takerGets = Currency.fromOperation(attrs.takerGets);
                obj.takerPays = Currency.fromOperation(attrs.takerPays);
                obj.amount = attrs.amount.toString();
                obj.price = attrs.price._attributes.n / attrs.price._attributes.d;
                obj.offerId = attrs.offerId.toString();
                break;
            case "accountMerge":
github stellar / js-stellar-sdk / src / operation.js View on Github external
obj.type = "changeTrust";
                obj.line = Currency.fromOperation(attrs.line);
                break;
            case "allowTrust":
                obj.type = "allowTrust";
                obj.trustor = encodeBase58Check("accountId", attrs.trustor);
                obj.currencyCode = attrs.currency._value.toString();
                if (obj.currencyCode[3] === "\0") {
                    obj.currencyCode = obj.currencyCode.slice(0,3);
                }
                obj.authorize = attrs.authorize;
                break;
            case "setOption":
                obj.type = "setOptions";
                if (attrs.inflationDest) {
                    obj.inflationDest = encodeBase58Check("accountId", attrs.inflationDest);
                }
                if (attrs.clearFlags) {
                    obj.clearFlags = attrs.clearFlags;
                }
                if (attrs.setFlags) {
                    obj.setFlags = attrs.setFlags;
                }
                if (attrs.thresholds) {
                    obj.thresholds = {
                        weight: Number(attrs.thresholds[0]),
                        low: Number(attrs.thresholds[1]),
                        medium: Number(attrs.thresholds[2]),
                        high: Number(attrs.thresholds[3]),
                    };
                }
                if (attrs.signer) {
github stellar / js-stellar-sdk / src / operation.js View on Github external
case "pathPayment":
                obj.type = "pathPayment";
                obj.sendCurrency = Currency.fromOperation(attrs.sendCurrency);
                obj.sendMax = attrs.sendMax.toString();
                obj.destination = encodeBase58Check("accountId", attrs.destination);
                obj.destCurrency = Currency.fromOperation(attrs.destCurrency);
                obj.destAmount = attrs.destAmount.toString();
                obj.path = attrs.path;
                break;
            case "changeTrust":
                obj.type = "changeTrust";
                obj.line = Currency.fromOperation(attrs.line);
                break;
            case "allowTrust":
                obj.type = "allowTrust";
                obj.trustor = encodeBase58Check("accountId", attrs.trustor);
                obj.currencyCode = attrs.currency._value.toString();
                if (obj.currencyCode[3] === "\0") {
                    obj.currencyCode = obj.currencyCode.slice(0,3);
                }
                obj.authorize = attrs.authorize;
                break;
            case "setOption":
                obj.type = "setOptions";
                if (attrs.inflationDest) {
                    obj.inflationDest = encodeBase58Check("accountId", attrs.inflationDest);
                }
                if (attrs.clearFlags) {
                    obj.clearFlags = attrs.clearFlags;
                }
                if (attrs.setFlags) {
                    obj.setFlags = attrs.setFlags;
github stellar / js-stellar-sdk / src / operation.js View on Github external
static operationToObject(operation) {
        let obj = {};
        let attrs = operation.body._value && operation.body._value._attributes;
        switch (operation.body._switch.name) {
            case "createAccount":
                obj.type = "createAccount";
                obj.destination = encodeBase58Check("accountId", attrs.destination);
                obj.startingBalance = attrs.startingBalance.toString();
                break;
            case "payment":
                obj.type = "payment";
                obj.destination = encodeBase58Check("accountId", attrs.destination);
                obj.currency = Currency.fromOperation(attrs.currency);
                obj.amount = attrs.amount.toString();
                break;
            case "pathPayment":
                obj.type = "pathPayment";
                obj.sendCurrency = Currency.fromOperation(attrs.sendCurrency);
                obj.sendMax = attrs.sendMax.toString();
                obj.destination = encodeBase58Check("accountId", attrs.destination);
                obj.destCurrency = Currency.fromOperation(attrs.destCurrency);
                obj.destAmount = attrs.destAmount.toString();
                obj.path = attrs.path;