liftedinit / many-js

JavaScript implementation of the MANY protocol
Apache License 2.0
5 stars 7 forks source link

feat: Support for tokens namespace #81

Closed stanleyjones closed 1 year ago

stanleyjones commented 2 years ago

Description

Related Issue

Fixes liftedinit/roadmap#21

Testing

Added unit tests for the above functions and fixed a bug where automatically adding a nonce wouldn't work outside of browsers.

Breaking Changes (if applicable)

None. Everything is under a new namespace.

stanleyjones commented 2 years ago

Are we testing somewhere that the CBOR encoding/decoding works?

They're not great but there are some in the /src/message directory. The tests in this PR are focused on the payloads for this namespace.

stanleyjones commented 1 year ago

@hansl We do use maps everywhere internally. I feel like one of the high-level design goals of ManyJs is to allow developers to do this...

network.tokens.create({
  summary: {
    name: "MyToken",
    symbol: "MTK",
    precision: 9,
  },
  owner: address,
  distribution: new Map([[address, BigInt(inputs.amount)]]),
});

...instead of this...

network.tokens.create(new Map([
  [0, new Map([
    [0, "MyToken"],
    [1, "MTK"],
    [2, 9],
  ]),
  [1, address],
  [2, new Map([[address, BigInt(inputs.amount)]])],
]);

Is that reasonable?

stanleyjones commented 1 year ago

Okay, comments addressed. The PR is already approved so I'll merge assuming tests pass.