Skip to content

Commit

Permalink
[worker] implement balance_unshield trusted call
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Apr 8, 2024
1 parent 911ca61 commit 29473cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/worker-api/src/worker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ describe('worker', () => {
});
});

describe('balance unshield should work', () => {
it('should return value', async () => {
const shard = worker.createType('ShardIdentifier', bs58.decode(network.mrenclave));
const params = worker.createType('BalanceUnshieldArgs', [alice.address, bob.address, 1100000000000, shard])
const result = await worker.balanceUnshieldFunds(alice, shard, network.mrenclave, params);
console.log('balance unshield result', result.toHuman());
expect(result).toBeDefined();
});
});

// Tests specific for the encointer protocol
describe('encointer-worker', () => {
describe('getTotalIssuance', () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/worker-api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {KeyringPair} from '@polkadot/keyring/types';
import type {AccountId, Balance, Hash, Moment} from '@polkadot/types/interfaces/runtime';
import type {
Attestation,
BalanceTransferArgs,
BalanceTransferArgs, BalanceUnshieldArgs,
CommunityIdentifier,
MeetupIndexType,
ParticipantIndexType,
Expand Down Expand Up @@ -244,6 +244,12 @@ export class EncointerWorker extends WebSocketAsPromised implements IEncointerWo
return this.sendTrustedCall(call, shard, options);
}

public async balanceUnshieldFunds(accountOrPubKey: KeyringPair | PubKeyPinPair, shard: ShardIdentifier, mrenclave: string, params: BalanceUnshieldArgs, options: CallOptions = {} as CallOptions): Promise<Hash> {
const nonce = await this.getNonce(accountOrPubKey, mrenclave, options);
const call = createTrustedCall(this, ['balance_unshield', 'BalanceUnshieldArgs'], accountOrPubKey, shard, mrenclave, nonce, params);
return this.sendTrustedCall(call, shard, options);
}

async sendTrustedCall(call: TrustedCallSigned, shard: ShardIdentifier, options: CallOptions = {} as CallOptions): Promise<Hash> {
if (this.shieldingKey() == undefined) {
const key = await this.getShieldingKey(options);
Expand Down

0 comments on commit 29473cc

Please sign in to comment.