Skip to content

Commit c624299

Browse files
committed
v1.7.1
1 parent 9a0503a commit c624299

File tree

3 files changed

+140
-1
lines changed

3 files changed

+140
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { BlockchainType, Dialect } from '../../sdk';
2+
import { NodeDialectSolanaWalletAdapter, Solana, SolanaSdkFactory } from '..';
3+
import { Keypair } from '@solana/web3.js';
4+
import bs58 from 'bs58';
5+
6+
async function main() {
7+
const monitor = Dialect.sdk<Solana>(
8+
{
9+
// environment: 'development',
10+
environment: 'development',
11+
},
12+
SolanaSdkFactory.create({
13+
wallet: new NodeDialectSolanaWalletAdapter(
14+
Keypair.fromSecretKey(
15+
new Uint8Array([
16+
56, 111, 31, 152, 56, 138, 122, 34, 150, 99, 14, 65, 41, 148, 28,
17+
58, 223, 101, 10, 31, 12, 146, 175, 132, 212, 6, 19, 222, 92, 177,
18+
36, 123, 65, 246, 202, 251, 197, 105, 179, 188, 65, 163, 200, 12,
19+
235, 148, 133, 28, 213, 61, 233, 180, 235, 110, 52, 2, 94, 136, 193,
20+
46, 225, 253, 48, 144,
21+
]),
22+
),
23+
),
24+
}),
25+
);
26+
const uint8Array = new Uint8Array([
27+
248, 80, 183, 221, 66, 144, 97, 254, 75, 101, 186, 117, 33, 130, 91, 117,
28+
214, 195, 11, 209, 227, 230, 64, 138, 128, 91, 90, 248, 47, 46, 201, 100, 4,
29+
1, 253, 87, 233, 66, 232, 136, 133, 117, 185, 11, 43, 114, 187, 61, 35, 102,
30+
45, 78, 9, 6, 60, 136, 233, 210, 41, 32, 18, 228, 241, 182,
31+
]);
32+
33+
const s = bs58.encode(uint8Array);
34+
console.log(s);
35+
return;
36+
const monitor2 = Dialect.sdk<Solana>(
37+
{
38+
// environment: 'development',
39+
environment: 'development',
40+
},
41+
SolanaSdkFactory.create({
42+
wallet: new NodeDialectSolanaWalletAdapter(
43+
Keypair.fromSecretKey(uint8Array),
44+
),
45+
}),
46+
);
47+
48+
const monitorDapp = await monitor.dapps.find();
49+
if (!monitorDapp) {
50+
const created = await monitor.dapps.create({
51+
name: 'MONITOR 1',
52+
blockchainType: BlockchainType.SOLANA,
53+
});
54+
}
55+
56+
const monitorDapp2 = await monitor2.dapps.find();
57+
if (!monitorDapp2) {
58+
const created = await monitor2.dapps.create({
59+
name: 'MONITOR 2',
60+
blockchainType: BlockchainType.SOLANA,
61+
});
62+
}
63+
64+
const promise = await monitor2.threads.find({
65+
otherMembers: ['6tBUD4bQzNehG3hQVtVFaGxre2P8rQoH99pubRtgSbSb'],
66+
});
67+
68+
console.log(promise?.lastMessage?.metadata);
69+
await monitorDapp2!.messages.send({
70+
title: 'Hello topic',
71+
message: 'Hello from monitor 2 topic',
72+
actions: [
73+
{ label: 'so', url: 'https://so.com' },
74+
{ label: 'sat', url: 'https://sat.com' },
75+
],
76+
notificationTypeId: '9b153418-f804-498d-9ea3-08f62359032a',
77+
});
78+
}
79+
80+
main().catch(console.error);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { BlockchainType, Dialect, DialectSdk } from '../../sdk';
2+
import { NodeDialectSolanaWalletAdapter, Solana, SolanaSdkFactory } from '..';
3+
import { Keypair } from '@solana/web3.js';
4+
5+
async function getOrCreateDapp(monitor: DialectSdk<Solana>) {
6+
const monitorDapp = await monitor.dapps.find();
7+
if (!monitorDapp) {
8+
const created = await monitor.dapps.create({
9+
name: 'MONITOR 1',
10+
blockchainType: BlockchainType.SOLANA,
11+
});
12+
return created;
13+
}
14+
return monitorDapp;
15+
}
16+
17+
async function main() {
18+
const sdk = Dialect.sdk<Solana>(
19+
{
20+
// environment: 'development',
21+
environment: 'development',
22+
},
23+
SolanaSdkFactory.create({
24+
wallet: new NodeDialectSolanaWalletAdapter(
25+
Keypair.fromSecretKey(
26+
new Uint8Array([
27+
248, 80, 183, 221, 66, 144, 97, 254, 75, 101, 186, 117, 33, 130, 91,
28+
117, 214, 195, 11, 209, 227, 230, 64, 138, 128, 91, 90, 248, 47, 46,
29+
201, 100, 4, 1, 253, 87, 233, 66, 232, 136, 133, 117, 185, 11, 43,
30+
114, 187, 61, 35, 102, 45, 78, 9, 6, 60, 136, 233, 210, 41, 32, 18,
31+
228, 241, 182,
32+
]),
33+
),
34+
),
35+
}),
36+
);
37+
const dapp = await getOrCreateDapp(sdk);
38+
39+
await dapp.messages.send({
40+
title: 'Hello topic 1',
41+
message: 'Hello from monitor 1 topic',
42+
actions: [
43+
{ label: 'so', url: 'https://so.com' },
44+
{ label: 'sat', url: 'https://sat.com' },
45+
],
46+
notificationTypeId: '9b153418-f804-498d-9ea3-08f62359032a',
47+
});
48+
await dapp.messages.send({
49+
title: 'Hello topic 2',
50+
message: 'Hello from monitor 2 topic',
51+
actions: [
52+
{ label: 'le', url: 'https://le.com' },
53+
{ label: 'zhat', url: 'https://zhat.com' },
54+
],
55+
notificationTypeId: 'dd20b141-ca09-4fde-9b36-19ac2560edca',
56+
});
57+
}
58+
59+
main().catch(console.error);

packages/sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dialectlabs/sdk",
3-
"version": "1.7.0",
3+
"version": "1.7.1",
44
"repository": "[email protected]:dialectlabs/sdk.git",
55
"author": "dialectlabs",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)