From 79c0bf57e1d32769d8c0d9ba856f1145695c5072 Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Fri, 14 May 2021 14:06:39 +0200 Subject: [PATCH 1/2] Revamp all tools to allow tx multiple signatures --- src/client/LumClient.ts | 34 ++++++++--- src/types/Doc.ts | 7 +-- src/types/DocSigner.ts | 8 +++ src/types/index.ts | 1 + src/utils/commons.ts | 19 ++++++ src/utils/transactions.ts | 44 +++++++++----- src/wallet/LumLedgerWallet.ts | 11 +++- src/wallet/LumPaperWallet.ts | 11 +++- tests/client.test.ts | 111 +++++++++++++++++++++++++--------- 9 files changed, 185 insertions(+), 61 deletions(-) create mode 100644 src/types/DocSigner.ts diff --git a/src/client/LumClient.ts b/src/client/LumClient.ts index 37d3972..1902ed9 100644 --- a/src/client/LumClient.ts +++ b/src/client/LumClient.ts @@ -242,17 +242,31 @@ export class LumClient { /** * Signs the messages using the provided wallet and builds the transaction * - * @param wallet signing wallet + * @param wallet signing wallet or wallets for multi signature * @param doc document to sign */ - signTx = async (wallet: LumWallet, doc: LumTypes.Doc): Promise => { - const account = await this.getAccount(wallet.getAddress()); - if (!account) { - throw new Error('Account not found'); + signTx = async (wallet: LumWallet | LumWallet[], doc: LumTypes.Doc): Promise => { + let wallets: LumWallet[] = []; + if (Array.isArray(wallet)) { + wallets = wallet; + } else { + wallets = [wallet]; + } + + if (wallets.length < 1) { + throw new Error('At least one wallet is required to sign the transaction'); + } + const signDoc = LumUtils.generateSignDoc(doc, 0, wallets[0].signingMode()); + const signatures: Uint8Array[] = []; + + for (let i = 0; i < wallets.length; i++) { + const account = await this.getAccount(wallets[i].getAddress()); + if (!account) { + throw new Error(`Account not found for wallet at index ${i}`); + } + signatures.push(await wallets[i].signTransaction(doc)); } - const signDoc = LumUtils.generateSignDoc(doc, wallet.getPublicKey(), wallet.signingMode()); - const signature = await wallet.signTransaction(doc); - return LumUtils.generateTxBytes(signDoc, signature); + return LumUtils.generateTxBytes(signDoc, signatures); }; /** @@ -269,10 +283,10 @@ export class LumClient { /** * Signs and broadcast the transaction using the specified wallet and messages * - * @param wallet signing wallet + * @param wallet signing wallet or wallets for multi signature * @param doc document to sign and broadcast as a transaction */ - signAndBroadcastTx = async (wallet: LumWallet, doc: LumTypes.Doc): Promise => { + signAndBroadcastTx = async (wallet: LumWallet | LumWallet[], doc: LumTypes.Doc): Promise => { const signedTx = await this.signTx(wallet, doc); return this.broadcastTx(signedTx); }; diff --git a/src/types/Doc.ts b/src/types/Doc.ts index 13e1509..315559b 100644 --- a/src/types/Doc.ts +++ b/src/types/Doc.ts @@ -1,9 +1,8 @@ import { Message } from '../messages'; import { Fee } from './Fee'; +import { DocSigner } from './DocSigner'; export interface Doc { - /** account_number is the account number of the account in state */ - accountNumber: number; /** * chain_id is the unique identifier of the chain this transaction targets. * It prevents signed transactions from being used on another chain by an @@ -23,7 +22,7 @@ export interface Doc { */ messages: Message[]; /** - * Transction sequence number + * Transction auth signers */ - sequence: number; + signers: DocSigner[]; } diff --git a/src/types/DocSigner.ts b/src/types/DocSigner.ts new file mode 100644 index 0000000..930fd43 --- /dev/null +++ b/src/types/DocSigner.ts @@ -0,0 +1,8 @@ +export interface DocSigner { + /** the account number of the account in state */ + accountNumber: number; + /** current account sequence */ + sequence: number; + /** account public key */ + publicKey: Uint8Array; +} diff --git a/src/types/index.ts b/src/types/index.ts index 29be443..94ffa61 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -6,6 +6,7 @@ export * from './Fee'; export * from './Description'; export * from './Commission'; export * from './CommissionRates'; +export * from './DocSigner'; export * from './Doc'; export * from './SignDoc'; export * from './SignMsg'; diff --git a/src/utils/commons.ts b/src/utils/commons.ts index 5c7c619..f942f10 100644 --- a/src/utils/commons.ts +++ b/src/utils/commons.ts @@ -1,5 +1,7 @@ export { isNonNullObject, isUint8Array } from '@cosmjs/utils'; +import { toHex } from './encoding'; + /** * Sorts an object properties recursively. * @@ -24,3 +26,20 @@ export const sortJSON = (jsonObj: T): T => { } return newObject as T; }; + +/** + * Find the index of an Uint8Array element in an array of Uint8Array. + * + * @param arr Array to search elem + * @param elem Elem to search in array + * @returns The index of the element in the array or -1 + */ +export const uint8IndexOf = (arr: Uint8Array[], elem: Uint8Array) => { + const hexElem = toHex(elem); + for (let i = 0; i < arr.length; i++) { + if (hexElem === toHex(arr[i])) { + return i; + } + } + return -1; +}; diff --git a/src/utils/transactions.ts b/src/utils/transactions.ts index c523777..43c7d44 100644 --- a/src/utils/transactions.ts +++ b/src/utils/transactions.ts @@ -3,11 +3,11 @@ import { Int53 } from '@cosmjs/math'; import { Secp256k1, Secp256k1Signature } from '@cosmjs/crypto'; import { makeAuthInfoBytes, makeSignBytes } from '@cosmjs/proto-signing'; -import { TxRaw } from '../codec/cosmos/tx/v1beta1/tx'; +import { TxRaw, AuthInfo } from '../codec/cosmos/tx/v1beta1/tx'; import { SignMode } from '../codec/cosmos/tx/signing/v1beta1/signing'; import { LumMessageSigner } from '../constants'; -import { Fee, Doc, SignDoc, SignMsg } from '../types'; +import { Fee, Doc, SignDoc, SignMsg, DocSigner } from '../types'; import { LumRegistry } from '../registry'; import { sortJSON } from './commons'; import { sha256, toAscii, Bech32 } from './encoding'; @@ -16,24 +16,38 @@ import { getAddressFromPublicKey, publicKeyToProto } from './keys'; /** * Generate transaction auth info payload * - * @param publicKey wallet public key (secp256k1) + * @param docSigners Document signers * @param fee requested fee - * @param sequence account sequence number + * @param signMode signing mode */ -export const generateAuthInfoBytes = (publicKey: Uint8Array, fee: Fee, sequence: number, signMode: SignMode): Uint8Array => { - const pubkeyAny = publicKeyToProto(publicKey); - const gasLimit = Int53.fromString(fee.gas).toNumber(); - return makeAuthInfoBytes([pubkeyAny], fee.amount, gasLimit, sequence, signMode); +export const generateAuthInfoBytes = (docSigners: DocSigner[], fee: Fee, signMode: SignMode): Uint8Array => { + const authInfo = { + signerInfos: docSigners.map((signer: DocSigner) => ({ + publicKey: publicKeyToProto(signer.publicKey), + modeInfo: { + single: { mode: signMode }, + }, + sequence: Long.fromNumber(signer.sequence), + })), + fee: { + amount: [...fee.amount], + gasLimit: Long.fromNumber(Int53.fromString(fee.gas).toNumber()), + }, + }; + return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish(); }; /** * Generate transaction doc to be signed * * @param doc document to create the sign version - * @param publicKey public key used for signature + * @param signerIdx index of the signer in the signers field used to specify the accountNumber for signature purpose * @param signMode signing mode for the transaction */ -export const generateSignDoc = (doc: Doc, publicKey: Uint8Array, signMode: SignMode): SignDoc => { +export const generateSignDoc = (doc: Doc, signerIdx: number, signMode: SignMode): SignDoc => { + if (signerIdx < 0 || signerIdx > doc.signers.length) { + throw new Error('Invalid doc signer index'); + } const txBody = { messages: doc.messages, memo: doc.memo, @@ -45,9 +59,9 @@ export const generateSignDoc = (doc: Doc, publicKey: Uint8Array, signMode: SignM return { bodyBytes, - authInfoBytes: generateAuthInfoBytes(publicKey, doc.fee, doc.sequence, signMode), + authInfoBytes: generateAuthInfoBytes(doc.signers, doc.fee, signMode), chainId: doc.chainId, - accountNumber: Long.fromNumber(doc.accountNumber), + accountNumber: Long.fromNumber(doc.signers[signerIdx].accountNumber), }; }; @@ -75,13 +89,13 @@ export const generateSignature = async (hashedMessage: Uint8Array, privateKey: U * Generate transaction bytes to broadcast * * @param signDoc sign doc (as generated by the generateSignDoc function) - * @param signature transaction signature (as generated by the generateSignature function) + * @param signatures transaction signatures (as generated by the generateSignature function) */ -export const generateTxBytes = (signDoc: SignDoc, signature: Uint8Array) => { +export const generateTxBytes = (signDoc: SignDoc, signatures: Uint8Array[]) => { const txRaw = TxRaw.fromPartial({ bodyBytes: signDoc.bodyBytes, authInfoBytes: signDoc.authInfoBytes, - signatures: [signature], + signatures: signatures, }); return Uint8Array.from(TxRaw.encode(txRaw).finish()); }; diff --git a/src/wallet/LumLedgerWallet.ts b/src/wallet/LumLedgerWallet.ts index 481b7f7..47d6464 100644 --- a/src/wallet/LumLedgerWallet.ts +++ b/src/wallet/LumLedgerWallet.ts @@ -52,13 +52,20 @@ export class LumLedgerWallet extends LumWallet { // Useful doc & code: // sign call: https://github.com/LedgerHQ/ledgerjs/blob/master/packages/hw-app-cosmos/src/Cosmos.js // Expected tx format: https://github.com/cosmos/ledger-cosmos/blob/master/docs/TXSPEC.md + const signerIndex = LumUtils.uint8IndexOf( + doc.signers.map((signer) => signer.publicKey), + this.publicKey as Uint8Array, + ); + if (signerIndex === -1) { + throw new Error('Signer not found in document'); + } const msg = { - 'account_number': doc.accountNumber.toString(), + 'account_number': doc.signers[signerIndex].accountNumber.toString(), 'chain_id': doc.chainId, 'fee': doc.fee, 'memo': doc.memo, 'msgs': doc.messages.map((msg) => LumAminoRegistry.toAmino(msg)), - 'sequence': doc.sequence.toString(), + 'sequence': doc.signers[signerIndex].sequence.toString(), }; const { signature, return_code } = await this.cosmosApp.sign(this.hdPath, JSON.stringify(LumUtils.sortJSON(msg))); if (!signature || return_code === 0) { diff --git a/src/wallet/LumPaperWallet.ts b/src/wallet/LumPaperWallet.ts index c127a09..ec1cfc2 100644 --- a/src/wallet/LumPaperWallet.ts +++ b/src/wallet/LumPaperWallet.ts @@ -4,7 +4,7 @@ import { LumWallet } from '.'; export class LumPaperWallet extends LumWallet { private readonly mnemonic?: string; - private privateKey?: Uint8Array; + public privateKey?: Uint8Array; /** * Create a LumPaperWallet instance based on a mnemonic or a private key @@ -48,7 +48,14 @@ export class LumPaperWallet extends LumWallet { if (!this.privateKey || !this.publicKey) { throw new Error('No account selected.'); } - const signDoc = LumUtils.generateSignDoc(doc, this.getPublicKey(), this.signingMode()); + const signerIndex = LumUtils.uint8IndexOf( + doc.signers.map((signer) => signer.publicKey), + this.publicKey as Uint8Array, + ); + if (signerIndex === -1) { + throw new Error('Signer not found in document'); + } + const signDoc = LumUtils.generateSignDoc(doc, signerIndex, this.signingMode()); const signBytes = LumUtils.generateSignDocBytes(signDoc); const hashedMessage = LumUtils.sha256(signBytes); const signature = await LumUtils.generateSignature(hashedMessage, this.privateKey); diff --git a/tests/client.test.ts b/tests/client.test.ts index c3d9d85..356a8b2 100644 --- a/tests/client.test.ts +++ b/tests/client.test.ts @@ -1,44 +1,59 @@ -import { LumWallet, LumWalletFactory, LumClient, LumUtils, LumConstants, LumRegistry, LumTypes, LumMessages } from "../src"; -import axios from "axios"; -import Long from "long"; +import { LumWallet, LumWalletFactory, LumClient, LumUtils, LumConstants, LumRegistry, LumTypes, LumMessages, LumPaperWallet } from '../src'; +import axios from 'axios'; +import Long from 'long'; const sleep = (millis: number): Promise => { - return new Promise(resolve => setTimeout(resolve, millis)); + return new Promise((resolve) => setTimeout(resolve, millis)); }; const randomString = (): string => { return Math.random().toString(36).substring(7); -} +}; -describe("LumClient", () => { +describe('LumClient', () => { let clt: LumClient; let w1: LumWallet; let w2: LumWallet; beforeAll(async () => { - clt = await LumClient.connect("http://node0.testnet.lum.network/rpc"); + clt = await LumClient.connect('http://node0.testnet.lum.network/rpc'); // Prepare the wallets w1 = await LumWalletFactory.fromMnemonic(LumUtils.generateMnemonic()); w2 = await LumWalletFactory.fromMnemonic(LumUtils.generateMnemonic()); + expect(w1.getAddress()).not.toEqual(w2.getAddress()); // Seed them with faucet coins each await axios.get(`https://bridge.testnet.lum.network/faucet/${w1.getAddress()}`); await axios.get(`https://bridge.testnet.lum.network/faucet/${w2.getAddress()}`); + const faucetResult = new Promise((resolve, reject) => { + let it = 0; + const rec = setInterval(async () => { + const balance = await clt.getBalanceUnverified(w1.getAddress(), LumConstants.MicroLumDenom); + if (balance && balance.amount && parseInt(balance.amount) > 0) { + resolve(true); + } else if (it >= 20) { + clearInterval(rec); + reject(); + } + it++; + }, 1000); + }); + expect(faucetResult).resolves.toBeTruthy(); }); afterAll(async () => { await expect(clt.disconnect()).resolves.toBeTruthy(); }); - it("Should be able to use beam features", async () => { + it('Should be able to use beam features', async () => { const beamId = randomString(); // Here we wait until the faucet transaction get dispatched and the account finally exists on the blockchain // This should be improved since... you know... let acc: LumTypes.Account = null; - while(acc === null){ + while (acc === null) { acc = await clt.getAccount(w1.getAddress()); await sleep(1000); } @@ -46,33 +61,39 @@ describe("LumClient", () => { const chainId = await clt.getChainId(); - const openBeamMsg = LumMessages.BuildMsgOpenBeam(beamId, w1.getAddress(), new Long(100), "test", null, null); + const openBeamMsg = LumMessages.BuildMsgOpenBeam(beamId, w1.getAddress(), new Long(100), 'test', null, null); const fee = { - amount: [{ denom: LumConstants.MicroLumDenom, amount: '1' }], - gas: '100000', + amount: [{ denom: LumConstants.MicroLumDenom, amount: '1' }], + gas: '100000', }; const doc = { - accountNumber: acc.accountNumber, - chainId, - fee: fee, - memo: 'Just a open beam transaction', - messages: [openBeamMsg], - sequence: acc.sequence, + accountNumber: acc.accountNumber, + chainId, + fee: fee, + memo: 'Just a open beam transaction', + messages: [openBeamMsg], + signers: [ + { + accountNumber: acc.accountNumber, + sequence: acc.sequence, + publicKey: w1.getPublicKey(), + }, + ], }; const tx = await clt.signAndBroadcastTx(w1, doc); expect(tx.deliverTx.code).toBe(0); - }) + }); - it("Should expose basic information", async () => { + it('Should expose basic information', async () => { const height = (await clt.getBlockHeight()) - 1; - expect(clt.getChainId()).resolves.toEqual("lumnetwork-testnet"); + expect(clt.getChainId()).resolves.toEqual('lumnetwork-testnet'); expect(height).toBeGreaterThan(0); expect(clt.getBlock(height)).resolves.toBeTruthy(); }); - it("should expose tendermint rpcs", async () => { + it('should expose tendermint rpcs', async () => { const height = (await clt.getBlockHeight()) - 1; expect(height).toBeGreaterThan(0); expect(clt.tmClient.health()).resolves.toBeNull(); @@ -85,7 +106,7 @@ describe("LumClient", () => { expect(clt.tmClient.validatorsAll(height)).resolves.toBeTruthy(); }); - it("Should expose bank module", async () => { + it('Should expose bank module', async () => { const supplies = await clt.queryClient.bank.unverified.totalSupply(); expect(supplies).toBeTruthy(); expect(supplies.length).toBeGreaterThan(0); @@ -94,7 +115,7 @@ describe("LumClient", () => { expect(parseFloat(lumSupply.amount)).toBeGreaterThan(0); }); - it("Should expose staking module", async () => { + it('Should expose staking module', async () => { const validators = await clt.tmClient.validatorsAll(); expect(validators.validators.length).toBeGreaterThanOrEqual(1); const block = await clt.getBlock(); @@ -116,7 +137,7 @@ describe("LumClient", () => { expect(bootVal).toBeTruthy(); // Get staking validator by matching it using pubkeys - const stakers = await clt.queryClient.staking.unverified.validators("BOND_STATUS_BONDED"); + const stakers = await clt.queryClient.staking.unverified.validators('BOND_STATUS_BONDED'); const bootStak = stakers.validators.filter((s) => LumUtils.toHex((LumRegistry.decode(s.consensusPubkey) as LumTypes.PubKey).key) === LumUtils.toHex(bootVal.pubkey.data))[0]; expect(bootVal).toBeTruthy(); @@ -134,7 +155,7 @@ describe("LumClient", () => { expect(parseFloat(lumBalance.amount)).toBeGreaterThan(0); }); - it("Should expose distribution module", async () => { + it('Should expose distribution module', async () => { // Get validators const validators = await clt.tmClient.validatorsAll(); expect(validators.validators.length).toBeGreaterThanOrEqual(1); @@ -147,7 +168,7 @@ describe("LumClient", () => { expect(bootVal).toBeTruthy(); // Get genesis validator account address - const stakers = await clt.queryClient.staking.unverified.validators("BOND_STATUS_BONDED"); + const stakers = await clt.queryClient.staking.unverified.validators('BOND_STATUS_BONDED'); const bootStak = stakers.validators.filter((s) => LumUtils.toHex((LumRegistry.decode(s.consensusPubkey) as LumTypes.PubKey).key) === LumUtils.toHex(bootVal.pubkey.data))[0]; expect(bootVal).toBeTruthy(); @@ -164,7 +185,41 @@ describe("LumClient", () => { expect(delegValidators.validators.length).toBeGreaterThan(0); }); - it("Should open a beam", async () => { + it('Should open a beam', async () => {}); + + it('Should allow multiple signers per transaction', async () => { + const acc1 = await clt.getAccount(w1.getAddress()); + const acc2 = await clt.getAccount(w2.getAddress()); + const chainId = await clt.getChainId(); + const fee = { + amount: [{ denom: LumConstants.MicroLumDenom, amount: '1' }], + gas: '300000', + }; + + const doc = { + accountNumber: 0, //acc1.accountNumber, + chainId, + fee: fee, + memo: 'Just a open beam transaction', + messages: [ + LumMessages.BuildMsgSend(w1.getAddress(), w2.getAddress(), [{ denom: LumConstants.MicroLumDenom, amount: '99' }]), + LumMessages.BuildMsgSend(w2.getAddress(), w1.getAddress(), [{ denom: LumConstants.MicroLumDenom, amount: '99' }]), + ], + signers: [ + { + accountNumber: acc1.accountNumber, + sequence: acc1.sequence, + publicKey: w1.getPublicKey(), + }, + { + accountNumber: acc2.accountNumber, + sequence: acc2.sequence, + publicKey: w2.getPublicKey(), + }, + ], + }; + const res = await clt.signAndBroadcastTx([w1, w2], doc); + expect(LumUtils.broadcastTxCommitSuccess(res)); }); }); From 9986cbb4924d67433e80e487f2aa89ac225adcce Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Fri, 14 May 2021 14:08:51 +0200 Subject: [PATCH 2/2] Update documentation --- CONTRIBUTING.md | 32 ++--- docs/README.md | 7 +- docs/lib/classes/lumclient.md | 8 +- docs/lib/classes/lumpaperwallet.md | 2 +- .../lummessages.msgbeginredelegate.md | 39 ------ .../lummessages.msgcreatevalidator.md | 59 --------- .../lib/interfaces/lummessages.msgdelegate.md | 32 ----- .../lummessages.msgeditvalidator.md | 43 ------ .../lummessages.msgfundcommunitypool.md | 25 ---- .../interfaces/lummessages.msgmintandsend.md | 26 ---- .../interfaces/lummessages.msgmultisend.md | 24 ---- docs/lib/interfaces/lummessages.msgsend.md | 31 ----- .../lummessages.msgsetwithdrawaddress.md | 25 ---- .../interfaces/lummessages.msgundelegate.md | 32 ----- .../lummessages.msgwithdrawdelegatorreward.md | 25 ---- ...messages.msgwithdrawvalidatorcommission.md | 18 --- docs/lib/interfaces/lumtypes.doc.md | 17 +-- docs/lib/interfaces/lumtypes.docsigner.md | 35 +++++ docs/lib/modules/lummessages.md | 124 +++++++++++++----- docs/lib/modules/lumtypes.md | 1 + docs/lib/modules/lumutils.md | 35 +++-- 21 files changed, 185 insertions(+), 455 deletions(-) delete mode 100644 docs/lib/interfaces/lummessages.msgbeginredelegate.md delete mode 100644 docs/lib/interfaces/lummessages.msgcreatevalidator.md delete mode 100644 docs/lib/interfaces/lummessages.msgdelegate.md delete mode 100644 docs/lib/interfaces/lummessages.msgeditvalidator.md delete mode 100644 docs/lib/interfaces/lummessages.msgfundcommunitypool.md delete mode 100644 docs/lib/interfaces/lummessages.msgmintandsend.md delete mode 100644 docs/lib/interfaces/lummessages.msgmultisend.md delete mode 100644 docs/lib/interfaces/lummessages.msgsend.md delete mode 100644 docs/lib/interfaces/lummessages.msgsetwithdrawaddress.md delete mode 100644 docs/lib/interfaces/lummessages.msgundelegate.md delete mode 100644 docs/lib/interfaces/lummessages.msgwithdrawdelegatorreward.md delete mode 100644 docs/lib/interfaces/lummessages.msgwithdrawvalidatorcommission.md create mode 100644 docs/lib/interfaces/lumtypes.docsigner.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da82749..d18bb21 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing When contributing to this repository, please first discuss the change you wish to make via issue, -email, or any other method with the owners of this repository before making a change. +email, or any other method with the owners of this repository before making a change. Please note we have a code of conduct, please follow it in all your interactions with the project. @@ -10,7 +10,7 @@ Please note we have a code of conduct, please follow it in all your interactions 1. Ensure any install or build dependencies are removed before the end of the layer when doing a build. 2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. 3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). -4. You may merge the Pull Request in once you have the approval of one core team member, or if you do not have permission to do that, you may request a reviewer to merge it for you. +4. You may merge the Pull Request in once you have the approval of one core team member, or if you do not have permission to do that, you may request a reviewer to merge it for you. ## Code of Conduct @@ -25,19 +25,19 @@ nationality, personal appearance, race, religion, or sexual identity and orienta Examples of behavior that contributes to creating a positive environment include: -* Using welcoming language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ### Our Responsibilities @@ -50,14 +50,14 @@ threatening, offensive, or harmful. ### Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. +representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ### Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact [ at ] lum.network. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact [ at ] lum.network. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. @@ -70,4 +70,4 @@ members of the project's leadership. This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/docs/README.md b/docs/README.md index f8dd2c9..abac906 100644 --- a/docs/README.md +++ b/docs/README.md @@ -158,12 +158,15 @@ const fee = { const account = await testnetClient.getAccount(wallet.getAddress()); // Create the transaction document const doc = { - accountNumber: account.accountNumber, chainId, fee: fee, memo: 'my transaction memo', messages: [sendMsg], - sequence: account.sequence, + signers: [{ + accountNumber: account.accountNumber, + sequence: account.sequence, + publicKey: wallet.getPublicKey(), + }], }; // Sign and broadcast the transaction using the client const broadcastResult = await clt.signAndBroadcastTx(w1, doc); diff --git a/docs/lib/classes/lumclient.md b/docs/lib/classes/lumclient.md index 0740be1..051fe6b 100644 --- a/docs/lib/classes/lumclient.md +++ b/docs/lib/classes/lumclient.md @@ -285,7 +285,7 @@ ___ ### signAndBroadcastTx -▸ **signAndBroadcastTx**(`wallet`: [*LumWallet*](lumwallet.md), `doc`: [*Doc*](../interfaces/lumtypes.doc.md)): *Promise* +▸ **signAndBroadcastTx**(`wallet`: [*LumWallet*](lumwallet.md) \| [*LumWallet*](lumwallet.md)[], `doc`: [*Doc*](../interfaces/lumtypes.doc.md)): *Promise* Signs and broadcast the transaction using the specified wallet and messages @@ -293,7 +293,7 @@ Signs and broadcast the transaction using the specified wallet and messages Name | Type | Description | :------ | :------ | :------ | -`wallet` | [*LumWallet*](lumwallet.md) | signing wallet | +`wallet` | [*LumWallet*](lumwallet.md) \| [*LumWallet*](lumwallet.md)[] | signing wallet or wallets for multi signature | `doc` | [*Doc*](../interfaces/lumtypes.doc.md) | document to sign and broadcast as a transaction | **Returns:** *Promise* @@ -302,7 +302,7 @@ ___ ### signTx -▸ **signTx**(`wallet`: [*LumWallet*](lumwallet.md), `doc`: [*Doc*](../interfaces/lumtypes.doc.md)): *Promise* +▸ **signTx**(`wallet`: [*LumWallet*](lumwallet.md) \| [*LumWallet*](lumwallet.md)[], `doc`: [*Doc*](../interfaces/lumtypes.doc.md)): *Promise* Signs the messages using the provided wallet and builds the transaction @@ -310,7 +310,7 @@ Signs the messages using the provided wallet and builds the transaction Name | Type | Description | :------ | :------ | :------ | -`wallet` | [*LumWallet*](lumwallet.md) | signing wallet | +`wallet` | [*LumWallet*](lumwallet.md) \| [*LumWallet*](lumwallet.md)[] | signing wallet or wallets for multi signature | `doc` | [*Doc*](../interfaces/lumtypes.doc.md) | document to sign | **Returns:** *Promise* diff --git a/docs/lib/classes/lumpaperwallet.md b/docs/lib/classes/lumpaperwallet.md index 05a8218..8930d79 100644 --- a/docs/lib/classes/lumpaperwallet.md +++ b/docs/lib/classes/lumpaperwallet.md @@ -67,7 +67,7 @@ ___ ### privateKey -• `Private` `Optional` **privateKey**: *undefined* \| *Uint8Array* +• `Optional` **privateKey**: *undefined* \| *Uint8Array* ___ diff --git a/docs/lib/interfaces/lummessages.msgbeginredelegate.md b/docs/lib/interfaces/lummessages.msgbeginredelegate.md deleted file mode 100644 index faf79c4..0000000 --- a/docs/lib/interfaces/lummessages.msgbeginredelegate.md +++ /dev/null @@ -1,39 +0,0 @@ -# Interface: MsgBeginRedelegate - -[LumMessages](../modules/lummessages.md).MsgBeginRedelegate - -MsgBeginRedelegate defines a SDK message for performing a redelegation -of coins from a delegator and source validator to a destination validator. - -## Table of contents - -### Properties - -- [amount](lummessages.msgbeginredelegate.md#amount) -- [delegatorAddress](lummessages.msgbeginredelegate.md#delegatoraddress) -- [validatorDstAddress](lummessages.msgbeginredelegate.md#validatordstaddress) -- [validatorSrcAddress](lummessages.msgbeginredelegate.md#validatorsrcaddress) - -## Properties - -### amount - -• `Optional` **amount**: *undefined* \| [*Coin*](lumtypes.coin.md) - -___ - -### delegatorAddress - -• **delegatorAddress**: *string* - -___ - -### validatorDstAddress - -• **validatorDstAddress**: *string* - -___ - -### validatorSrcAddress - -• **validatorSrcAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgcreatevalidator.md b/docs/lib/interfaces/lummessages.msgcreatevalidator.md deleted file mode 100644 index 5977377..0000000 --- a/docs/lib/interfaces/lummessages.msgcreatevalidator.md +++ /dev/null @@ -1,59 +0,0 @@ -# Interface: MsgCreateValidator - -[LumMessages](../modules/lummessages.md).MsgCreateValidator - -MsgCreateValidator defines a SDK message for creating a new validator. - -## Table of contents - -### Properties - -- [commission](lummessages.msgcreatevalidator.md#commission) -- [delegatorAddress](lummessages.msgcreatevalidator.md#delegatoraddress) -- [description](lummessages.msgcreatevalidator.md#description) -- [minSelfDelegation](lummessages.msgcreatevalidator.md#minselfdelegation) -- [pubkey](lummessages.msgcreatevalidator.md#pubkey) -- [validatorAddress](lummessages.msgcreatevalidator.md#validatoraddress) -- [value](lummessages.msgcreatevalidator.md#value) - -## Properties - -### commission - -• `Optional` **commission**: *undefined* \| [*CommissionRates*](lumtypes.commissionrates.md) - -___ - -### delegatorAddress - -• **delegatorAddress**: *string* - -___ - -### description - -• `Optional` **description**: *undefined* \| [*Description*](lumtypes.description.md) - -___ - -### minSelfDelegation - -• **minSelfDelegation**: *string* - -___ - -### pubkey - -• `Optional` **pubkey**: *undefined* \| Any - -___ - -### validatorAddress - -• **validatorAddress**: *string* - -___ - -### value - -• `Optional` **value**: *undefined* \| [*Coin*](lumtypes.coin.md) diff --git a/docs/lib/interfaces/lummessages.msgdelegate.md b/docs/lib/interfaces/lummessages.msgdelegate.md deleted file mode 100644 index 9c79fd6..0000000 --- a/docs/lib/interfaces/lummessages.msgdelegate.md +++ /dev/null @@ -1,32 +0,0 @@ -# Interface: MsgDelegate - -[LumMessages](../modules/lummessages.md).MsgDelegate - -MsgDelegate defines a SDK message for performing a delegation of coins -from a delegator to a validator. - -## Table of contents - -### Properties - -- [amount](lummessages.msgdelegate.md#amount) -- [delegatorAddress](lummessages.msgdelegate.md#delegatoraddress) -- [validatorAddress](lummessages.msgdelegate.md#validatoraddress) - -## Properties - -### amount - -• `Optional` **amount**: *undefined* \| [*Coin*](lumtypes.coin.md) - -___ - -### delegatorAddress - -• **delegatorAddress**: *string* - -___ - -### validatorAddress - -• **validatorAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgeditvalidator.md b/docs/lib/interfaces/lummessages.msgeditvalidator.md deleted file mode 100644 index 382b366..0000000 --- a/docs/lib/interfaces/lummessages.msgeditvalidator.md +++ /dev/null @@ -1,43 +0,0 @@ -# Interface: MsgEditValidator - -[LumMessages](../modules/lummessages.md).MsgEditValidator - -MsgEditValidator defines a SDK message for editing an existing validator. - -## Table of contents - -### Properties - -- [commissionRate](lummessages.msgeditvalidator.md#commissionrate) -- [description](lummessages.msgeditvalidator.md#description) -- [minSelfDelegation](lummessages.msgeditvalidator.md#minselfdelegation) -- [validatorAddress](lummessages.msgeditvalidator.md#validatoraddress) - -## Properties - -### commissionRate - -• **commissionRate**: *string* - -We pass a reference to the new commission rate and min self delegation as -it's not mandatory to update. If not updated, the deserialized rate will be -zero with no way to distinguish if an update was intended. -REF: #2373 - -___ - -### description - -• `Optional` **description**: *undefined* \| [*Description*](lumtypes.description.md) - -___ - -### minSelfDelegation - -• **minSelfDelegation**: *string* - -___ - -### validatorAddress - -• **validatorAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgfundcommunitypool.md b/docs/lib/interfaces/lummessages.msgfundcommunitypool.md deleted file mode 100644 index 29b0fed..0000000 --- a/docs/lib/interfaces/lummessages.msgfundcommunitypool.md +++ /dev/null @@ -1,25 +0,0 @@ -# Interface: MsgFundCommunityPool - -[LumMessages](../modules/lummessages.md).MsgFundCommunityPool - -MsgFundCommunityPool allows an account to directly -fund the community pool. - -## Table of contents - -### Properties - -- [amount](lummessages.msgfundcommunitypool.md#amount) -- [depositor](lummessages.msgfundcommunitypool.md#depositor) - -## Properties - -### amount - -• **amount**: [*Coin*](lumtypes.coin.md)[] - -___ - -### depositor - -• **depositor**: *string* diff --git a/docs/lib/interfaces/lummessages.msgmintandsend.md b/docs/lib/interfaces/lummessages.msgmintandsend.md deleted file mode 100644 index bbf8fcd..0000000 --- a/docs/lib/interfaces/lummessages.msgmintandsend.md +++ /dev/null @@ -1,26 +0,0 @@ -# Interface: MsgMintAndSend - -[LumMessages](../modules/lummessages.md).MsgMintAndSend - -MsgMintAndSend defines a SDK message asking the faucet module to send you -a set of coins, for testing purposes only. -This module is ONLY enabled in testnet - -## Table of contents - -### Properties - -- [mintTime](lummessages.msgmintandsend.md#minttime) -- [minter](lummessages.msgmintandsend.md#minter) - -## Properties - -### mintTime - -• **mintTime**: Date - -___ - -### minter - -• **minter**: *string* diff --git a/docs/lib/interfaces/lummessages.msgmultisend.md b/docs/lib/interfaces/lummessages.msgmultisend.md deleted file mode 100644 index d73dd7e..0000000 --- a/docs/lib/interfaces/lummessages.msgmultisend.md +++ /dev/null @@ -1,24 +0,0 @@ -# Interface: MsgMultiSend - -[LumMessages](../modules/lummessages.md).MsgMultiSend - -MsgMultiSend represents an arbitrary multi-in, multi-out send message. - -## Table of contents - -### Properties - -- [input](lummessages.msgmultisend.md#input) -- [output](lummessages.msgmultisend.md#output) - -## Properties - -### input - -• **input**: { `address`: *string* ; `coins`: [*Coin*](lumtypes.coin.md)[] }[] - -___ - -### output - -• **output**: { `address`: *string* ; `coins`: [*Coin*](lumtypes.coin.md)[] }[] diff --git a/docs/lib/interfaces/lummessages.msgsend.md b/docs/lib/interfaces/lummessages.msgsend.md deleted file mode 100644 index 6cb7c94..0000000 --- a/docs/lib/interfaces/lummessages.msgsend.md +++ /dev/null @@ -1,31 +0,0 @@ -# Interface: MsgSend - -[LumMessages](../modules/lummessages.md).MsgSend - -MsgSend represents a message to send coins from one account to another. - -## Table of contents - -### Properties - -- [amount](lummessages.msgsend.md#amount) -- [fromAddress](lummessages.msgsend.md#fromaddress) -- [toAddress](lummessages.msgsend.md#toaddress) - -## Properties - -### amount - -• **amount**: [*Coin*](lumtypes.coin.md)[] - -___ - -### fromAddress - -• **fromAddress**: *string* - -___ - -### toAddress - -• **toAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgsetwithdrawaddress.md b/docs/lib/interfaces/lummessages.msgsetwithdrawaddress.md deleted file mode 100644 index e010724..0000000 --- a/docs/lib/interfaces/lummessages.msgsetwithdrawaddress.md +++ /dev/null @@ -1,25 +0,0 @@ -# Interface: MsgSetWithdrawAddress - -[LumMessages](../modules/lummessages.md).MsgSetWithdrawAddress - -MsgSetWithdrawAddress sets the withdraw address for -a delegator (or validator self-delegation). - -## Table of contents - -### Properties - -- [delegatorAddress](lummessages.msgsetwithdrawaddress.md#delegatoraddress) -- [withdrawAddress](lummessages.msgsetwithdrawaddress.md#withdrawaddress) - -## Properties - -### delegatorAddress - -• **delegatorAddress**: *string* - -___ - -### withdrawAddress - -• **withdrawAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgundelegate.md b/docs/lib/interfaces/lummessages.msgundelegate.md deleted file mode 100644 index c7d70a3..0000000 --- a/docs/lib/interfaces/lummessages.msgundelegate.md +++ /dev/null @@ -1,32 +0,0 @@ -# Interface: MsgUndelegate - -[LumMessages](../modules/lummessages.md).MsgUndelegate - -MsgUndelegate defines a SDK message for performing an undelegation from a -delegate and a validator. - -## Table of contents - -### Properties - -- [amount](lummessages.msgundelegate.md#amount) -- [delegatorAddress](lummessages.msgundelegate.md#delegatoraddress) -- [validatorAddress](lummessages.msgundelegate.md#validatoraddress) - -## Properties - -### amount - -• `Optional` **amount**: *undefined* \| [*Coin*](lumtypes.coin.md) - -___ - -### delegatorAddress - -• **delegatorAddress**: *string* - -___ - -### validatorAddress - -• **validatorAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgwithdrawdelegatorreward.md b/docs/lib/interfaces/lummessages.msgwithdrawdelegatorreward.md deleted file mode 100644 index f38d27c..0000000 --- a/docs/lib/interfaces/lummessages.msgwithdrawdelegatorreward.md +++ /dev/null @@ -1,25 +0,0 @@ -# Interface: MsgWithdrawDelegatorReward - -[LumMessages](../modules/lummessages.md).MsgWithdrawDelegatorReward - -MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator -from a single validator. - -## Table of contents - -### Properties - -- [delegatorAddress](lummessages.msgwithdrawdelegatorreward.md#delegatoraddress) -- [validatorAddress](lummessages.msgwithdrawdelegatorreward.md#validatoraddress) - -## Properties - -### delegatorAddress - -• **delegatorAddress**: *string* - -___ - -### validatorAddress - -• **validatorAddress**: *string* diff --git a/docs/lib/interfaces/lummessages.msgwithdrawvalidatorcommission.md b/docs/lib/interfaces/lummessages.msgwithdrawvalidatorcommission.md deleted file mode 100644 index 14d348b..0000000 --- a/docs/lib/interfaces/lummessages.msgwithdrawvalidatorcommission.md +++ /dev/null @@ -1,18 +0,0 @@ -# Interface: MsgWithdrawValidatorCommission - -[LumMessages](../modules/lummessages.md).MsgWithdrawValidatorCommission - -MsgWithdrawValidatorCommission withdraws the full commission to the validator -address. - -## Table of contents - -### Properties - -- [validatorAddress](lummessages.msgwithdrawvalidatorcommission.md#validatoraddress) - -## Properties - -### validatorAddress - -• **validatorAddress**: *string* diff --git a/docs/lib/interfaces/lumtypes.doc.md b/docs/lib/interfaces/lumtypes.doc.md index 1d5932b..2445485 100644 --- a/docs/lib/interfaces/lumtypes.doc.md +++ b/docs/lib/interfaces/lumtypes.doc.md @@ -6,23 +6,14 @@ ### Properties -- [accountNumber](lumtypes.doc.md#accountnumber) - [chainId](lumtypes.doc.md#chainid) - [fee](lumtypes.doc.md#fee) - [memo](lumtypes.doc.md#memo) - [messages](lumtypes.doc.md#messages) -- [sequence](lumtypes.doc.md#sequence) +- [signers](lumtypes.doc.md#signers) ## Properties -### accountNumber - -• **accountNumber**: *number* - -account_number is the account number of the account in state - -___ - ### chainId • **chainId**: *string* @@ -57,8 +48,8 @@ Transactions messages ___ -### sequence +### signers -• **sequence**: *number* +• **signers**: [*DocSigner*](lumtypes.docsigner.md)[] -Transction sequence number +Transction auth signers diff --git a/docs/lib/interfaces/lumtypes.docsigner.md b/docs/lib/interfaces/lumtypes.docsigner.md new file mode 100644 index 0000000..fcb7490 --- /dev/null +++ b/docs/lib/interfaces/lumtypes.docsigner.md @@ -0,0 +1,35 @@ +# Interface: DocSigner + +[LumTypes](../modules/lumtypes.md).DocSigner + +## Table of contents + +### Properties + +- [accountNumber](lumtypes.docsigner.md#accountnumber) +- [publicKey](lumtypes.docsigner.md#publickey) +- [sequence](lumtypes.docsigner.md#sequence) + +## Properties + +### accountNumber + +• **accountNumber**: *number* + +the account number of the account in state + +___ + +### publicKey + +• **publicKey**: *Uint8Array* + +account public key + +___ + +### sequence + +• **sequence**: *number* + +current account sequence diff --git a/docs/lib/modules/lummessages.md b/docs/lib/modules/lummessages.md index 02b4f45..6c2246a 100644 --- a/docs/lib/modules/lummessages.md +++ b/docs/lib/modules/lummessages.md @@ -5,46 +5,40 @@ ### Interfaces - [Message](../interfaces/lummessages.message.md) -- [MsgBeginRedelegate](../interfaces/lummessages.msgbeginredelegate.md) -- [MsgCreateValidator](../interfaces/lummessages.msgcreatevalidator.md) -- [MsgDelegate](../interfaces/lummessages.msgdelegate.md) -- [MsgEditValidator](../interfaces/lummessages.msgeditvalidator.md) -- [MsgFundCommunityPool](../interfaces/lummessages.msgfundcommunitypool.md) -- [MsgMintAndSend](../interfaces/lummessages.msgmintandsend.md) -- [MsgMultiSend](../interfaces/lummessages.msgmultisend.md) -- [MsgSend](../interfaces/lummessages.msgsend.md) -- [MsgSetWithdrawAddress](../interfaces/lummessages.msgsetwithdrawaddress.md) -- [MsgUndelegate](../interfaces/lummessages.msgundelegate.md) -- [MsgWithdrawDelegatorReward](../interfaces/lummessages.msgwithdrawdelegatorreward.md) -- [MsgWithdrawValidatorCommission](../interfaces/lummessages.msgwithdrawvalidatorcommission.md) ### Variables - [MsgBeginRedelegateUrl](lummessages.md#msgbeginredelegateurl) +- [MsgCancelBeamUrl](lummessages.md#msgcancelbeamurl) +- [MsgClaimBeamUrl](lummessages.md#msgclaimbeamurl) - [MsgCreateValidatorUrl](lummessages.md#msgcreatevalidatorurl) - [MsgDelegateUrl](lummessages.md#msgdelegateurl) - [MsgEditValidatorUrl](lummessages.md#msgeditvalidatorurl) - [MsgFundCommunityPoolUrl](lummessages.md#msgfundcommunitypoolurl) -- [MsgMintAndSendUrl](lummessages.md#msgmintandsendurl) - [MsgMultiSendUrl](lummessages.md#msgmultisendurl) +- [MsgOpenBeamUrl](lummessages.md#msgopenbeamurl) - [MsgSendUrl](lummessages.md#msgsendurl) - [MsgSetWithdrawAddressUrl](lummessages.md#msgsetwithdrawaddressurl) - [MsgUndelegateUrl](lummessages.md#msgundelegateurl) +- [MsgUpdateBeamUrl](lummessages.md#msgupdatebeamurl) - [MsgWithdrawDelegatorRewardUrl](lummessages.md#msgwithdrawdelegatorrewardurl) - [MsgWithdrawValidatorCommissionUrl](lummessages.md#msgwithdrawvalidatorcommissionurl) ### Functions - [BuildMsgBeginRedelegate](lummessages.md#buildmsgbeginredelegate) +- [BuildMsgCancelBeam](lummessages.md#buildmsgcancelbeam) +- [BuildMsgClaimBeam](lummessages.md#buildmsgclaimbeam) - [BuildMsgCreateValidator](lummessages.md#buildmsgcreatevalidator) - [BuildMsgDelegate](lummessages.md#buildmsgdelegate) - [BuildMsgEditValidator](lummessages.md#buildmsgeditvalidator) - [BuildMsgFundCommunityPool](lummessages.md#buildmsgfundcommunitypool) -- [BuildMsgMintAndSend](lummessages.md#buildmsgmintandsend) - [BuildMsgMultiSend](lummessages.md#buildmsgmultisend) +- [BuildMsgOpenBeam](lummessages.md#buildmsgopenbeam) - [BuildMsgSend](lummessages.md#buildmsgsend) - [BuildMsgSetWithdrawAddress](lummessages.md#buildmsgsetwithdrawaddress) - [BuildMsgUndelegate](lummessages.md#buildmsgundelegate) +- [BuildMsgUpdateBeam](lummessages.md#buildmsgupdatebeam) - [BuildMsgWithdrawDelegatorReward](lummessages.md#buildmsgwithdrawdelegatorreward) - [BuildMsgWithdrawValidatorCommission](lummessages.md#buildmsgwithdrawvalidatorcommission) @@ -56,6 +50,18 @@ ___ +### MsgCancelBeamUrl + +• `Const` **MsgCancelBeamUrl**: */lum.network.beam.MsgCancelBeam*= '/lum.network.beam.MsgCancelBeam' + +___ + +### MsgClaimBeamUrl + +• `Const` **MsgClaimBeamUrl**: */lum.network.beam.MsgClaimBeam*= '/lum.network.beam.MsgClaimBeam' + +___ + ### MsgCreateValidatorUrl • `Const` **MsgCreateValidatorUrl**: */cosmos.staking.v1beta1.MsgCreateValidator*= '/cosmos.staking.v1beta1.MsgCreateValidator' @@ -80,15 +86,15 @@ ___ ___ -### MsgMintAndSendUrl +### MsgMultiSendUrl -• `Const` **MsgMintAndSendUrl**: */lum.network.faucet.MsgMintAndSend*= '/lum.network.faucet.MsgMintAndSend' +• `Const` **MsgMultiSendUrl**: */cosmos.bank.v1beta1.MsgMultiSend*= '/cosmos.bank.v1beta1.MsgMultiSend' ___ -### MsgMultiSendUrl +### MsgOpenBeamUrl -• `Const` **MsgMultiSendUrl**: */cosmos.bank.v1beta1.MsgMultiSend*= '/cosmos.bank.v1beta1.MsgMultiSend' +• `Const` **MsgOpenBeamUrl**: */lum.network.beam.MsgOpenBeam*= '/lum.network.beam.MsgOpenBeam' ___ @@ -110,6 +116,12 @@ ___ ___ +### MsgUpdateBeamUrl + +• `Const` **MsgUpdateBeamUrl**: */lum.network.beam.MsgUpdateBeam*= '/lum.network.beam.MsgUpdateBeam' + +___ + ### MsgWithdrawDelegatorRewardUrl • `Const` **MsgWithdrawDelegatorRewardUrl**: */cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward*= '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward' @@ -139,6 +151,37 @@ Name | Type | ___ +### BuildMsgCancelBeam + +▸ `Const`**BuildMsgCancelBeam**(`updater`: *string*, `id`: *string*): [*Message*](../interfaces/lummessages.message.md) + +#### Parameters: + +Name | Type | +:------ | :------ | +`updater` | *string* | +`id` | *string* | + +**Returns:** [*Message*](../interfaces/lummessages.message.md) + +___ + +### BuildMsgClaimBeam + +▸ `Const`**BuildMsgClaimBeam**(`claimer`: *string*, `id`: *string*, `secret`: *string*): [*Message*](../interfaces/lummessages.message.md) + +#### Parameters: + +Name | Type | +:------ | :------ | +`claimer` | *string* | +`id` | *string* | +`secret` | *string* | + +**Returns:** [*Message*](../interfaces/lummessages.message.md) + +___ + ### BuildMsgCreateValidator ▸ `Const`**BuildMsgCreateValidator**(`validatorAddress`: *string*, `delegatorAddress`: *string*, `minSelfDelegation`: *string*, `commission?`: [*CommissionRates*](../interfaces/lumtypes.commissionrates.md), `description?`: [*Description*](../interfaces/lumtypes.description.md), `value?`: [*Coin*](../interfaces/lumtypes.coin.md), `pubkey?`: Any): [*Message*](../interfaces/lummessages.message.md) @@ -207,36 +250,35 @@ Name | Type | ___ -### BuildMsgMintAndSend +### BuildMsgMultiSend -▸ `Const`**BuildMsgMintAndSend**(`minter`: *string*, `mintTime`: Date): *object* +▸ `Const`**BuildMsgMultiSend**(`inputs`: Input[], `outputs`: Output[]): [*Message*](../interfaces/lummessages.message.md) #### Parameters: Name | Type | :------ | :------ | -`minter` | *string* | -`mintTime` | Date | +`inputs` | Input[] | +`outputs` | Output[] | -**Returns:** *object* - -Name | Type | -:------ | :------ | -`typeUrl` | *string* | -`value` | [*MsgMintAndSend*](../interfaces/lummessages.msgmintandsend.md) | +**Returns:** [*Message*](../interfaces/lummessages.message.md) ___ -### BuildMsgMultiSend +### BuildMsgOpenBeam -▸ `Const`**BuildMsgMultiSend**(`input`: { `address`: *string* ; `coins`: [*Coin*](../interfaces/lumtypes.coin.md)[] }[], `output`: { `address`: *string* ; `coins`: [*Coin*](../interfaces/lumtypes.coin.md)[] }[]): [*Message*](../interfaces/lummessages.message.md) +▸ `Const`**BuildMsgOpenBeam**(`id`: *string*, `creator`: *string*, `amount`: Long, `secret`: *string*, `reward?`: BeamReward, `review?`: BeamReview): [*Message*](../interfaces/lummessages.message.md) #### Parameters: Name | Type | :------ | :------ | -`input` | { `address`: *string* ; `coins`: [*Coin*](../interfaces/lumtypes.coin.md)[] }[] | -`output` | { `address`: *string* ; `coins`: [*Coin*](../interfaces/lumtypes.coin.md)[] }[] | +`id` | *string* | +`creator` | *string* | +`amount` | Long | +`secret` | *string* | +`reward?` | BeamReward | +`review?` | BeamReview | **Returns:** [*Message*](../interfaces/lummessages.message.md) @@ -289,6 +331,24 @@ Name | Type | ___ +### BuildMsgUpdateBeam + +▸ `Const`**BuildMsgUpdateBeam**(`updater`: *string*, `id`: *string*, `amount`: Long, `reward?`: BeamReward, `review?`: BeamReview): [*Message*](../interfaces/lummessages.message.md) + +#### Parameters: + +Name | Type | +:------ | :------ | +`updater` | *string* | +`id` | *string* | +`amount` | Long | +`reward?` | BeamReward | +`review?` | BeamReview | + +**Returns:** [*Message*](../interfaces/lummessages.message.md) + +___ + ### BuildMsgWithdrawDelegatorReward ▸ `Const`**BuildMsgWithdrawDelegatorReward**(`delegatorAddress`: *string*, `validatorAddress`: *string*): [*Message*](../interfaces/lummessages.message.md) diff --git a/docs/lib/modules/lumtypes.md b/docs/lib/modules/lumtypes.md index c2dcd38..ef56bd7 100644 --- a/docs/lib/modules/lumtypes.md +++ b/docs/lib/modules/lumtypes.md @@ -10,6 +10,7 @@ - [CommissionRates](../interfaces/lumtypes.commissionrates.md) - [Description](../interfaces/lumtypes.description.md) - [Doc](../interfaces/lumtypes.doc.md) +- [DocSigner](../interfaces/lumtypes.docsigner.md) - [Fee](../interfaces/lumtypes.fee.md) - [Log](../interfaces/lumtypes.log.md) - [LogAttribute](../interfaces/lumtypes.logattribute.md) diff --git a/docs/lib/modules/lumutils.md b/docs/lib/modules/lumutils.md index efcff6d..4e42aa5 100644 --- a/docs/lib/modules/lumutils.md +++ b/docs/lib/modules/lumutils.md @@ -41,6 +41,7 @@ - [sha3](lumutils.md#sha3) - [sortJSON](lumutils.md#sortjson) - [toJSON](lumutils.md#tojson) +- [uint8IndexOf](lumutils.md#uint8indexof) - [verifySignMsg](lumutils.md#verifysignmsg) - [verifySignature](lumutils.md#verifysignature) @@ -103,7 +104,7 @@ ___ ### generateAuthInfoBytes -▸ `Const`**generateAuthInfoBytes**(`publicKey`: *Uint8Array*, `fee`: [*Fee*](../interfaces/lumtypes.fee.md), `sequence`: *number*, `signMode`: SignMode): *Uint8Array* +▸ `Const`**generateAuthInfoBytes**(`docSigners`: [*DocSigner*](../interfaces/lumtypes.docsigner.md)[], `fee`: [*Fee*](../interfaces/lumtypes.fee.md), `signMode`: SignMode): *Uint8Array* Generate transaction auth info payload @@ -111,10 +112,9 @@ Generate transaction auth info payload Name | Type | Description | :------ | :------ | :------ | -`publicKey` | *Uint8Array* | wallet public key (secp256k1) | +`docSigners` | [*DocSigner*](../interfaces/lumtypes.docsigner.md)[] | Document signers | `fee` | [*Fee*](../interfaces/lumtypes.fee.md) | requested fee | -`sequence` | *number* | account sequence number | -`signMode` | SignMode | - | +`signMode` | SignMode | signing mode | **Returns:** *Uint8Array* @@ -167,7 +167,7 @@ ___ ### generateSignDoc -▸ `Const`**generateSignDoc**(`doc`: [*Doc*](../interfaces/lumtypes.doc.md), `publicKey`: *Uint8Array*, `signMode`: SignMode): [*SignDoc*](../interfaces/lumtypes.signdoc.md) +▸ `Const`**generateSignDoc**(`doc`: [*Doc*](../interfaces/lumtypes.doc.md), `signerIdx`: *number*, `signMode`: SignMode): [*SignDoc*](../interfaces/lumtypes.signdoc.md) Generate transaction doc to be signed @@ -176,7 +176,7 @@ Generate transaction doc to be signed Name | Type | Description | :------ | :------ | :------ | `doc` | [*Doc*](../interfaces/lumtypes.doc.md) | document to create the sign version | -`publicKey` | *Uint8Array* | public key used for signature | +`signerIdx` | *number* | index of the signer in the signers field used to specify the accountNumber for signature purpose | `signMode` | SignMode | signing mode for the transaction | **Returns:** [*SignDoc*](../interfaces/lumtypes.signdoc.md) @@ -218,7 +218,7 @@ ___ ### generateTxBytes -▸ `Const`**generateTxBytes**(`signDoc`: [*SignDoc*](../interfaces/lumtypes.signdoc.md), `signature`: *Uint8Array*): *Uint8Array* +▸ `Const`**generateTxBytes**(`signDoc`: [*SignDoc*](../interfaces/lumtypes.signdoc.md), `signatures`: *Uint8Array*[]): *Uint8Array* Generate transaction bytes to broadcast @@ -227,7 +227,7 @@ Generate transaction bytes to broadcast Name | Type | Description | :------ | :------ | :------ | `signDoc` | [*SignDoc*](../interfaces/lumtypes.signdoc.md) | sign doc (as generated by the generateSignDoc function) | -`signature` | *Uint8Array* | transaction signature (as generated by the generateSignature function) | +`signatures` | *Uint8Array*[] | transaction signatures (as generated by the generateSignature function) | **Returns:** *Uint8Array* @@ -604,6 +604,25 @@ Name | Type | Description | ___ +### uint8IndexOf + +▸ `Const`**uint8IndexOf**(`arr`: *Uint8Array*[], `elem`: *Uint8Array*): *number* + +Find the index of an Uint8Array element in an array of Uint8Array. + +#### Parameters: + +Name | Type | Description | +:------ | :------ | :------ | +`arr` | *Uint8Array*[] | Array to search elem | +`elem` | *Uint8Array* | Elem to search in array | + +**Returns:** *number* + +The index of the element in the array or -1 + +___ + ### verifySignMsg ▸ `Const`**verifySignMsg**(`msg`: [*SignMsg*](../interfaces/lumtypes.signmsg.md)): *Promise*