How to use the @cityofzion/neon-core.wallet.getScriptHashFromAddress function in @cityofzion/neon-core

To help you get started, we’ve selected a few @cityofzion/neon-core 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 CityOfZion / neon-js / packages / neon-nep5 / __tests__ / abi.ts View on Github external
test("balanceOf", () => {
  const resultFunction = abi.balanceOf(scriptHash, fromAddr);
  const resultScript = resultFunction().str;
  expect(resultScript).toBe(
    `14${u.reverseHex(
      wallet.getScriptHashFromAddress(fromAddr)
    )}51c10962616c616e63654f6667${u.reverseHex(scriptHash)}`
  );
});
github CityOfZion / neon-js / packages / neon-nep5 / src / abi.ts View on Github external
function addressToScriptHash(address: string): string {
  return u.reverseHex(wallet.getScriptHashFromAddress(address));
}
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
newTx.inputs.push(new TransactionInput({
                        prevIndex: item.n,
                        prevHash: item.txid.startsWith('0x') && item.txid.length === 66 ?
                            item.txid.substring(2) : item.txid
                    }));
                    if (curr >= fee) {
                        break;
                    }
                }
                const payback = this.global.mathSub(curr, fee);
                if (payback < 0) {
                    reject('no enough GAS to fee');
                    return;
                }
                if (payback > 0) {
                    const fromScript = wallet.getScriptHashFromAddress(from);
                    let gasAssetId = res[0].asset_id;
                    if (gasAssetId.startsWith('0x') && gasAssetId.length === 66) {
                        gasAssetId = gasAssetId.substring(2);
                    }
                    newTx.addOutput({ assetId: gasAssetId, value: this.global.mathSub(curr, fee), scriptHash: fromScript });
                }
                resolve(newTx);
            });
        });
github NeoNextClub / neoline / src / app / popup / notification / invoke / invoke.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const fromScript = wallet.getScriptHashFromAddress(this.neon.address);
            const toScript = this.scriptHash.startsWith('0x') && this.scriptHash.length === 42 ? this.scriptHash.substring(2) : this.scriptHash;
            let newTx = new tx.InvocationTransaction();
            if (this.scriptHash.length !== 42 && this.scriptHash.length !== 40) {
                this.chrome.windowCallback({
                    error: ERRORS.MALFORMED_INPUT,
                    return: requestTarget.Invoke,
                    ID: this.messageID
                });
                this.loading = false;
                this.loadingMsg = '';
                window.close();
                return null;
            }
            try {
                newTx.script = sc.createScript({
                    scriptHash: this.scriptHash.startsWith('0x') && this.scriptHash.length === 42 ? this.scriptHash.substring(2) : this.scriptHash,
github NeoNextClub / neoline / src / app / transfer / transfer.service.ts View on Github external
for (const item of res) {
                    curr = this.global.mathAdd(curr, parseFloat(item.value) || 0);
                    newTx.inputs.push(new TransactionInput({
                        prevIndex: item.n,
                        prevHash: item.txid.startsWith('0x') && item.txid.length === 66 ?
                            item.txid.substring(2) : item.txid }));
                    if (curr >= fee) {
                        break;
                    }
                }
                const payback = this.global.mathSub(curr, fee);
                if (payback < 0) {
                    observer.error('no enough GAS to fee');
                }
                if (payback > 0) {
                    const fromScript = wallet.getScriptHashFromAddress(from);
                    let gasAssetId = res[0].asset_id;
                    if (gasAssetId.startsWith('0x') && gasAssetId.length === 66) {
                        gasAssetId = gasAssetId.substring(2);
                    }
                    newTx.addOutput({ assetId: gasAssetId, value: this.global.mathSub(curr, fee), scriptHash: fromScript });
                }
                observer.next(newTx);
                observer.complete();
            });
        });
github CityOfZion / neon-js / packages / neon-nep5 / src / main.ts View on Github external
scriptHashArray.forEach(scriptHash => {
      if (address) {
        const addrScriptHash = u.reverseHex(
          wallet.getScriptHashFromAddress(address)
        );
        sb.emitAppCall(scriptHash, "name")
          .emitAppCall(scriptHash, "symbol")
          .emitAppCall(scriptHash, "decimals")
          .emitAppCall(scriptHash, "totalSupply")
          .emitAppCall(scriptHash, "balanceOf", [addrScriptHash]);
      } else {
        sb.emitAppCall(scriptHash, "name")
          .emitAppCall(scriptHash, "symbol")
          .emitAppCall(scriptHash, "decimals")
          .emitAppCall(scriptHash, "totalSupply");
      }
    });
github NeoNextClub / neoline / src / app / popup / notification / invoke / invoke.component.ts View on Github external
if (curr >= fee) {
                        break;
                    }
                }
                const payback = this.global.mathSub(curr, fee);
                if (payback < 0) {
                    reject('no enough GAS to fee');
                    this.chrome.windowCallback({
                        error: ERRORS.INSUFFICIENT_FUNDS,
                        return: requestTarget.Deploy,
                        ID: this.messageID
                    });
                    window.close();
                }
                if (payback > 0) {
                    const fromScript = wallet.getScriptHashFromAddress(from);
                    let gasAssetId = res[0].asset_id;
                    if (gasAssetId.startsWith('0x') && gasAssetId.length === 66) {
                        gasAssetId = gasAssetId.substring(2);
                    }
                    newTx.addOutput({ assetId: gasAssetId, value: this.global.mathSub(curr, fee), scriptHash: fromScript });
                }
                resolve(newTx);
            });
        });