How to use the @0xcert/ethereum-gateway.OrderKind.ASSET_LEDGER_DEPLOY_ORDER function in @0xcert/ethereum-gateway

To help you get started, we’ve selected a few @0xcert/ethereum-gateway 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 0xcert / framework / packages / 0xcert-client / src / core / controllers / deployments-controller.ts View on Github external
public async createDeployment(deployData: AssetLedgerDeploymentData, priority: Priority) {
    if (!this.context.authentication) {
      throw new Error('Client not connected. Please initialize your client first.');
    }
    const deployGateway = new Gateway(this.context.provider);
    const date = Date.now();
    const multiplier = new BigNumber(1000000000000000000);
    const paymentAmount = this.context.payment.assetDeployCost;
    const value = new BigNumber(paymentAmount).multipliedBy(multiplier);
    const assetLedgerDeployOrder = {
      kind: OrderKind.ASSET_LEDGER_DEPLOY_ORDER,
      makerId: this.context.provider.accountId,
      seed: date,
      expiration: Date.now() + 172800000, // 2 days
      tokenTransferData: {
        ledgerId: this.context.payment.tokenAddress,
        receiverId: this.context.payment.receiverAddress,
        value: value.toFixed(0),
      },
      assetLedgerData: deployData,
    };
    const claim = await deployGateway.sign(assetLedgerDeployOrder as AssetLedgerDeployOrder);
    delete assetLedgerDeployOrder.kind; // kind will be automatically assigned in the API
    return clientFetch(`${this.context.apiUrl}/deployments`, {
      method: 'POST',
      body: JSON.stringify({
        priority,