Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #23 from nervosnetwork/patch/multisig
Browse files Browse the repository at this point in the history
feat: supported autonomy in MultiSigService
  • Loading branch information
homura authored Aug 4, 2020
2 parents 85d80c1 + 148d73b commit 545c449
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/009-multi-sig.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const assetService = new AssetService(client, account1);
async function main() {
console.log(`creating multi-sig account`);
const multiSigReceipt = await multiSigService.write.generate_account({
autonomy: false,
addr_with_weight: [
{ address: account1.address, weight: 1 },
{ address: account2.address, weight: 1 },
Expand Down
32 changes: 32 additions & 0 deletions packages/muta-service/src/builtins/MultiSignatureService.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Client } from '@mutadev/client';
import { Account } from '@mutadev/account';
import { MultiSignatureService } from './MultiSignatureService';

const client = new Client();

const account1 = new Account(
'0x0000000000000000000000000000000000000000000000000000000000000001',
);
const account2 = new Account(
'0x0000000000000000000000000000000000000000000000000000000000000002',
);
const account3 = new Account(
'0x0000000000000000000000000000000000000000000000000000000000000003',
);

test('test MultiSignatureService', async () => {
const service = new MultiSignatureService(client, account1);
const receipt = await service.write.generate_account({
autonomy: false,
addr_with_weight: [
{ address: account1.address, weight: 1 },
{ address: account2.address, weight: 1 },
{ address: account3.address, weight: 1 },
],
memo: 'hello world',
owner: account1.address,
threshold: 2,
});

expect(Number(receipt.response.response.code)).toBe(0);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Address, SignedTransaction, Vec, u32 } from '@mutadev/types';
import { createServiceBindingClass, read, write } from '../create';

interface GenerateMultiSigAccountPayload {
autonomy: boolean;
owner: Address;
addr_with_weight: Vec<AddressWithWeight>;
threshold: u32;
Expand Down

0 comments on commit 545c449

Please sign in to comment.