|
| 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); |
0 commit comments