Skip to content

Commit

Permalink
Add member examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron committed Dec 16, 2023
1 parent 9eac65c commit 87e7a1e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/sdk/examples/member/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Build5, https } from '@build-5/sdk';
import { address } from '../utils/secret';

async function main() {
const origin = Build5.TEST;
const response = await https(origin)
.createMember({
address: address.bech32,
signature: '',
body: {
address: address.bech32,
},
});

console.log('Member uid: ', response.uid);
}

main().then(() => process.exit());
29 changes: 29 additions & 0 deletions packages/sdk/examples/member/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Dataset, Network } from '@build-5/interfaces';
import { API_KEY, Build5, https } from '@build-5/sdk';
import { address } from '../utils/secret';
import { walletSign } from '../utils/utils';

async function main() {
const origin = Build5.TEST;
const member = await https(origin).project(API_KEY[Build5.TEST]).dataset(Dataset.MEMBER).id(address.bech32).get();

const name = Math.random().toString().split('.')[1];
const signature = await walletSign(member.uid, address);
const response = await https(origin).project(API_KEY[Build5.TEST])
.dataset(Dataset.MEMBER)
.update({
address: address.bech32,
signature: signature.signature,
publicKey: {
hex: signature.publicKey,
network: Network.RMS,
},
body: {
name: name + '_fun',
},
});

console.log('Member updated: ', response);
}

main().then(() => process.exit());

0 comments on commit 87e7a1e

Please sign in to comment.