Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sdk/javascript] NEM - automatic population for fields levySize and messageEnvelopeSize #293

Closed
cryptoBeliever opened this issue Jul 4, 2022 · 2 comments · Fixed by #531
Assignees
Labels
sdk-javascript Related to the Javascript SDK. Status: WIP This issue or PR is a work in progress.

Comments

@cryptoBeliever
Copy link
Contributor

Current Behaviour

SDK user has to specify fields manually:

  • levySize
  • messageEnvelopeSize

Expected Behaviour

Fields levySize and messageEnvelopeSize can be calculated based on other values in the transaction. We don't need to force users to calculate and specify it manually.

The corresponding issue for Python SDK: #292

@gimre-xymcity
Copy link
Member

part of js sdk 3.0.4

@cryptoBeliever
Copy link
Contributor Author

I've tested JS SDK on the current dev branch, and SDK users don't need any more fill:

  • messageEnvelopeSize when sensing transfer transaction
  • levySize when sending mosaic definition transaction

I've not noticed any issues 👍

Example tx construction for transfer transaction:

const transferTransaction = facade.transactionFactory.create({
        type: 'transfer_transaction_v1',
        fee: BigInt(100000),
        signerPublicKey: keyPair.publicKey,
        recipientAddress: 'TAZLVBLIBA72UDZKY2N6PEW7SPQHHYOWIT4PRRNP',
        timestamp: Number(Math.ceil(timestamp / 1000)),
        deadline: Number(Math.ceil(timestamp / 1000 + 60 * 60)),
        amount: BigInt(1000000),
        message: {
            messageType: 'plain',
            message: 'Good Luck!'
        }
    });

Example ex construction for mosaic creation with levy:

const transferTransaction = facade.transactionFactory.create({
        type: 'mosaic_definition_transaction_v1',
        fee: 200000n,
        signerPublicKey: keyPair.publicKey,
        timestamp: Number(Math.ceil(timestamp / 1000)),
        deadline: Number(Math.ceil(timestamp / 1000 + 60 * 60)),
        rentalFee: 10000000n,
        rentalFeeSink: 'TBMOSAICOD4F54EE5CDMR23CCBGOAM2XSJBR5OLC',
        mosaicDefinition: {
           ownerPublicKey: keyPair.publicKey,
           id: {
               namespaceId: {
                   name: textEncoder.encode('supernamespace')
               },
               name: textEncoder.encode('awesome_mosaic5')
           },
           description: textEncoder.encode('Just testing'),
           properties: [
               { property: { name: textEncoder.encode('divisibility'), value: textEncoder.encode('0') } },
               { property: { name: textEncoder.encode('initialSupply'), value: textEncoder.encode('1000') } },
               { property: { name: textEncoder.encode('supplyMutable'), value: textEncoder.encode('true') } },
               { property: { name: textEncoder.encode('transferable'), value: textEncoder.encode('true') } }
           ],
           levy: {
             transferFeeType: 'absolute',
             recipientAddress: address,
             mosaicId: { namespaceId: { name: textEncoder.encode('nem') }, name: textEncoder.encode('xem') },
             fee: 632_0000n
           }
        }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk-javascript Related to the Javascript SDK. Status: WIP This issue or PR is a work in progress.
Projects
None yet
3 participants