How to use the @cityofzion/neon-core.tx.TxAttrUsage 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-api / src / funcs / common.ts View on Github external
export async function modifyTransactionForEmptyTransaction<
  U extends tx.BaseTransaction,
  T extends ManagedApiBasicConfig<u>
&gt;(config: T): Promise {
  if (config.tx!.inputs.length === 0 &amp;&amp; config.tx!.outputs.length === 0) {
    config.tx!.addAttribute(
      tx.TxAttrUsage.Script,
      u.reverseHex(wallet.getScriptHashFromAddress(config.account!.address))
    );
    // This adds some random bits to the transaction to prevent any hash collision.
    config.tx!.addRemark(
      Date.now().toString() + u.ab2hexstring(u.generateRandomArray(4))
    );
  }
  return config;
}

</u>
github CityOfZion / neon-js / packages / neon-api / __tests__ / func / smartcontract.ts View on Github external
test("add attribute if sendingFromSmartContract", async () => {
    const config = {
      account: {
        scriptHash: "abcd"
      },
      sendingFromSmartContract: "5b7074e873973a6ed3708862f219a6fbf4d1c411",
      tx: { addAttribute: jest.fn() }
    } as any;

    const result = await smartcontract.addAttributeIfExecutingAsSmartContract(
      config
    );
    expect(config.tx.addAttribute).toBeCalledWith(
      tx.TxAttrUsage.Script,
      "11c4d1f4fba619f2628870d36e3a9773e874705b"
    );
  });
});
github NeoNextClub / neoline / src / app / popup / notification / invoke / invoke.component.ts View on Github external
}
                    }
                } else {
                    if (this.fee > 0) {
                        try {
                            newTx = await this.addFee(this.neon.wallet.accounts[0].address, newTx, this.fee);
                        } catch (error) {
                            console.log(error);
                        }
                    }
                }
            } else {
                newTx.outputs = this.assetIntentOverrides.outlets;
                newTx.inputs = this.assetIntentOverrides.inputs;
            }
            newTx.addAttribute(tx.TxAttrUsage.Script, u.reverseHex(fromScript));
            const uniqTag = `from NEOLine at ${new Date().getTime()}`;
            newTx.addAttribute(tx.TxAttrUsage.Remark1, u.reverseHex(u.str2hexstring(uniqTag)));
            resolve(newTx);
        });
    }
github CityOfZion / neon-js / packages / neon-nep9 / src / extract.ts View on Github external
import { CONST, tx, u } from "@cityofzion/neon-core";

const requiresProcessing = [
  tx.TxAttrUsage.Description,
  tx.TxAttrUsage.DescriptionUrl,
  tx.TxAttrUsage.Remark,
  tx.TxAttrUsage.Remark2,
  tx.TxAttrUsage.Remark3,
  tx.TxAttrUsage.Remark4,
  tx.TxAttrUsage.Remark5,
  tx.TxAttrUsage.Remark6,
  tx.TxAttrUsage.Remark7,
  tx.TxAttrUsage.Remark8,
  tx.TxAttrUsage.Remark9,
  tx.TxAttrUsage.Remark10,
  tx.TxAttrUsage.Remark11,
  tx.TxAttrUsage.Remark12,
  tx.TxAttrUsage.Remark13,
  tx.TxAttrUsage.Remark14,
  tx.TxAttrUsage.Remark15
github CityOfZion / neon-js / packages / neon-nep9 / src / extract.ts View on Github external
import { CONST, tx, u } from "@cityofzion/neon-core";

const requiresProcessing = [
  tx.TxAttrUsage.Description,
  tx.TxAttrUsage.DescriptionUrl,
  tx.TxAttrUsage.Remark,
  tx.TxAttrUsage.Remark2,
  tx.TxAttrUsage.Remark3,
  tx.TxAttrUsage.Remark4,
  tx.TxAttrUsage.Remark5,
  tx.TxAttrUsage.Remark6,
  tx.TxAttrUsage.Remark7,
  tx.TxAttrUsage.Remark8,
  tx.TxAttrUsage.Remark9,
  tx.TxAttrUsage.Remark10,
  tx.TxAttrUsage.Remark11,
  tx.TxAttrUsage.Remark12,
  tx.TxAttrUsage.Remark13,
  tx.TxAttrUsage.Remark14,
  tx.TxAttrUsage.Remark15
];

export function extractAsset(params: {
  [key: string]: string;
}): string | undefined {
  if (!params.asset) {
    return undefined;
  }
  switch (params.asset) {
    case "neo":
      return CONST.ASSET_ID.NEO;
github CityOfZion / neon-js / packages / neon-api / src / funcs / smartcontract.ts View on Github external
export async function addAttributeIfExecutingAsSmartContract&lt;
  T extends ManagedApiBasicConfig
&gt;(config: T): Promise {
  if (!config.sendingFromSmartContract) {
    return config;
  }
  config.tx!.addAttribute(
    tx.TxAttrUsage.Script,
    u.reverseHex(config.sendingFromSmartContract)
  );
  return config;
}
github CityOfZion / neon-js / packages / neon-api / src / funcs / mint.ts View on Github external
export async function addAttributeForMintToken(
  config: DoInvokeConfig
): Promise {
  if (
    typeof config.script === "object" &amp;&amp;
    config.script.operation === "mintTokens" &amp;&amp;
    config.script.scriptHash
  ) {
    config.tx!.addAttribute(
      tx.TxAttrUsage.Script,
      u.reverseHex(config.script.scriptHash)
    );
  }
  return config;
}