@rainprotocolsdk/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Rain.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { GetMarketsParams, Market } from './markets/types';
2
+ import { EnterOptionTxParams, RawTransaction } from './tx/types';
3
+ export declare class Rain {
4
+ getPublicMarkets(params: GetMarketsParams): Promise<Market[]>;
5
+ buildBuyOptionRawTx(params: EnterOptionTxParams): RawTransaction;
6
+ }
package/dist/Rain.js ADDED
@@ -0,0 +1,10 @@
1
+ import { getMarkets } from './markets/getMarkets';
2
+ import { buildEnterOptionRawTx } from './tx/buildRawTransactions';
3
+ export class Rain {
4
+ async getPublicMarkets(params) {
5
+ return getMarkets(params);
6
+ }
7
+ buildBuyOptionRawTx(params) {
8
+ return buildEnterOptionRawTx(params);
9
+ }
10
+ }
@@ -0,0 +1,23 @@
1
+ import { RainConfig } from './types';
2
+ export declare class Rain {
3
+ private config;
4
+ private _client;
5
+ private _address;
6
+ constructor(config: RainConfig);
7
+ /**
8
+ * Initializes the Smart Account
9
+ */
10
+ connect(): Promise<`0x${string}`>;
11
+ /**
12
+ * Returns smart account address
13
+ */
14
+ get address(): `0x${string}`;
15
+ /**
16
+ * Returns smart account client
17
+ */
18
+ get client(): any;
19
+ /**
20
+ * Reset connection (optional)
21
+ */
22
+ disconnect(): void;
23
+ }
package/dist/Rainaa.js ADDED
@@ -0,0 +1,79 @@
1
+ import { custom, createWalletClient } from 'viem';
2
+ import { WalletClientSigner } from '@alchemy/aa-core';
3
+ import { alchemy } from "@account-kit/infra";
4
+ import { createSmartWalletClient } from "@account-kit/wallet-client";
5
+ export class Rain {
6
+ config;
7
+ _client = null;
8
+ _address = null;
9
+ constructor(config) {
10
+ if (!config.walletClient)
11
+ throw new Error('walletClient is required');
12
+ if (!config.alchemyApiKey)
13
+ throw new Error('alchemyApiKey is required');
14
+ if (!config.paymasterPolicyId)
15
+ throw new Error('paymasterPolicyId is required');
16
+ if (!config.chain)
17
+ throw new Error('chain is required');
18
+ console.log('Rain SDK initialized with config:', config);
19
+ this.config = config;
20
+ }
21
+ /**
22
+ * Initializes the Smart Account
23
+ */
24
+ async connect() {
25
+ if (this._address && this._client) {
26
+ return this._address;
27
+ }
28
+ try {
29
+ const signer = new WalletClientSigner(createWalletClient({
30
+ transport: custom(this.config.walletClient),
31
+ }), 'wallet');
32
+ const client = createSmartWalletClient({
33
+ chain: this.config.chain,
34
+ signer: signer,
35
+ policyId: this.config.paymasterPolicyId,
36
+ transport: alchemy({
37
+ apiKey: this.config.alchemyApiKey,
38
+ nodeRpcUrl: this.config.rpcUrl,
39
+ }),
40
+ });
41
+ const account = await client.requestAccount();
42
+ if (!account?.address) {
43
+ throw new Error('Failed to create smart account');
44
+ }
45
+ this._client = client;
46
+ this._address = account.address;
47
+ return account.address;
48
+ }
49
+ catch (err) {
50
+ console.error('[Rain SDK] connect failed:', err);
51
+ throw err;
52
+ }
53
+ }
54
+ /**
55
+ * Returns smart account address
56
+ */
57
+ get address() {
58
+ if (!this._address) {
59
+ throw new Error('Rain not connected. Call rain.connect() first.');
60
+ }
61
+ return this._address;
62
+ }
63
+ /**
64
+ * Returns smart account client
65
+ */
66
+ get client() {
67
+ if (!this._client) {
68
+ throw new Error('Rain not connected. Call rain.connect() first.');
69
+ }
70
+ return this._client;
71
+ }
72
+ /**
73
+ * Reset connection (optional)
74
+ */
75
+ disconnect() {
76
+ this._client = null;
77
+ this._address = null;
78
+ }
79
+ }