-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
37 lines (32 loc) · 1.38 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { LotusRPC } from '@filecoin-shipyard/lotus-client-rpc';
import { NodejsProvider } from '@filecoin-shipyard/lotus-client-provider-nodejs';
import { testnet } from '@filecoin-shipyard/lotus-client-schema';
// const url = 'ws://127.0.0.1:1234/rpc/v0';
const url = 'http://127.0.0.1:7777/rpc/v0';
// const url = 'wss://lotus.testground.ipfs.team/api/0/node/rpc/v0'
// const provider = new BrowserProvider(url)
// const provider = new NodejsProvider(url, { transport: 'http' })
const provider = new NodejsProvider(url);
const client = new LotusRPC(provider, { schema: testnet.fullNode });
async function run() {
try {
const defaultWalletAddress = await client.walletDefaultAddress();
console.log('Address', defaultWalletAddress);
const newWalletAddress = await client.walletNew(2); // no idea why 2
console.log('New address', newWalletAddress);
const channelInfo = await client.paychGet(
defaultWalletAddress,
newWalletAddress,
'20000'
);
console.log('Result of paychGet:', channelInfo);
const channelMessage = channelInfo['ChannelMessage'];
console.log('Waiting for ChannelMessage to be mined...');
const msgResult = await client.stateWaitMsg(channelMessage, 1); // confidence (depth) = 1
console.log('ChannelMessage mined:', msgResult);
} catch (e) {
console.error('client.version error', e);
}
await client.destroy();
}
run();