@magicblock-labs/ephemeral-rollups-sdk 0.3.1 → 0.3.4
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.
|
@@ -2,226 +2,115 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const magic_router_js_1 = require("../magic-router.js");
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
|
|
6
|
-
toBase58: () => address,
|
|
7
|
-
toString: () => address,
|
|
8
|
-
});
|
|
9
|
-
jest.mock("@solana/web3.js", () => {
|
|
10
|
-
const actual = jest.requireActual("@solana/web3.js");
|
|
11
|
-
return {
|
|
12
|
-
...actual,
|
|
13
|
-
Connection: jest.fn().mockImplementation(() => ({
|
|
14
|
-
rpcEndpoint: "http://localhost",
|
|
15
|
-
sendRawTransaction: jest.fn().mockResolvedValue("mock-signature"),
|
|
16
|
-
})),
|
|
17
|
-
Transaction: jest.fn().mockImplementation(() => ({
|
|
18
|
-
feePayer: mockPublicKey("mock-fee-payer"),
|
|
19
|
-
signature: [],
|
|
20
|
-
instructions: [
|
|
21
|
-
{
|
|
22
|
-
keys: [
|
|
23
|
-
{ pubkey: mockPublicKey("key1"), isSigner: true, isWritable: true },
|
|
24
|
-
{
|
|
25
|
-
pubkey: mockPublicKey("key2"),
|
|
26
|
-
isSigner: false,
|
|
27
|
-
isWritable: false,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
serialize: jest.fn(() => Buffer.from("mock")),
|
|
33
|
-
sign: jest.fn(),
|
|
34
|
-
})),
|
|
35
|
-
Keypair: jest.fn().mockImplementation(() => ({
|
|
36
|
-
publicKey: mockPublicKey("mock-public-key"),
|
|
37
|
-
sign: jest.fn(),
|
|
38
|
-
})),
|
|
39
|
-
PublicKey: jest
|
|
40
|
-
.fn()
|
|
41
|
-
.mockImplementation((address) => mockPublicKey(address)),
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
global.fetch = jest.fn(async () => Promise.resolve({
|
|
45
|
-
json: async () => Promise.resolve({ result: { blockhash: "mock-blockhash" } }),
|
|
46
|
-
}));
|
|
47
|
-
describe("prepareRouterTransaction", () => {
|
|
48
|
-
it("sets recentBlockhash and returns the transaction", async () => {
|
|
49
|
-
const connection = new web3_js_1.Connection("http://localhost");
|
|
50
|
-
const transaction = new web3_js_1.Transaction();
|
|
51
|
-
const result = await (0, magic_router_js_1.prepareMagicTransaction)(connection, transaction);
|
|
52
|
-
expect(result.recentBlockhash).toBe("mock-blockhash");
|
|
53
|
-
expect(global.fetch).toHaveBeenCalledWith("http://localhost", {
|
|
54
|
-
method: "POST",
|
|
55
|
-
headers: { "Content-Type": "application/json" },
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
jsonrpc: "2.0",
|
|
58
|
-
id: 1,
|
|
59
|
-
method: "getBlockhashForAccounts",
|
|
60
|
-
params: [["mock-fee-payer", "key1"]],
|
|
61
|
-
}),
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe("sendRouterTransaction", () => {
|
|
66
|
-
it("sets recentBlockhash, feePayer, signs, and sends the transaction", async () => {
|
|
67
|
-
const connection = new web3_js_1.Connection("http://localhost");
|
|
68
|
-
const transaction = new web3_js_1.Transaction();
|
|
69
|
-
const signers = [new web3_js_1.Keypair()];
|
|
70
|
-
const signature = await (0, magic_router_js_1.sendMagicTransaction)(connection, transaction, signers);
|
|
71
|
-
expect(transaction.recentBlockhash).toBe("mock-blockhash");
|
|
72
|
-
expect(transaction.feePayer?.toBase58()).toBe("mock-fee-payer");
|
|
73
|
-
expect(transaction.sign).toHaveBeenCalledWith(...signers);
|
|
74
|
-
expect(signature).toBe("mock-signature");
|
|
75
|
-
expect(global.fetch).toHaveBeenCalledWith("http://localhost", {
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers: { "Content-Type": "application/json" },
|
|
78
|
-
body: JSON.stringify({
|
|
79
|
-
jsonrpc: "2.0",
|
|
80
|
-
id: 1,
|
|
81
|
-
method: "getBlockhashForAccounts",
|
|
82
|
-
params: [["mock-fee-payer", "key1"]],
|
|
83
|
-
}),
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
5
|
+
global.fetch = jest.fn();
|
|
87
6
|
describe("getWritableAccounts", () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
instructions: [
|
|
92
|
-
{
|
|
93
|
-
keys: [
|
|
94
|
-
{ pubkey: mockPublicKey("key1"), isWritable: true },
|
|
95
|
-
{ pubkey: mockPublicKey("key2"), isWritable: false },
|
|
96
|
-
{ pubkey: mockPublicKey("key3"), isWritable: true },
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
const result = (0, magic_router_js_1.getWritableAccounts)(transaction);
|
|
102
|
-
expect(result).toEqual(["fee-payer", "key1", "key3"]);
|
|
103
|
-
});
|
|
104
|
-
it("handles transaction without feePayer", () => {
|
|
105
|
-
const transaction = {
|
|
106
|
-
feePayer: null,
|
|
107
|
-
instructions: [
|
|
108
|
-
{
|
|
109
|
-
keys: [
|
|
110
|
-
{ pubkey: mockPublicKey("key1"), isWritable: true },
|
|
111
|
-
{ pubkey: mockPublicKey("key2"), isWritable: false },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
};
|
|
116
|
-
const result = (0, magic_router_js_1.getWritableAccounts)(transaction);
|
|
117
|
-
expect(result).toEqual(["key1"]);
|
|
118
|
-
});
|
|
119
|
-
it("handles transaction without instructions", () => {
|
|
120
|
-
const transaction = {
|
|
121
|
-
feePayer: mockPublicKey("fee-payer"),
|
|
122
|
-
instructions: [],
|
|
123
|
-
};
|
|
124
|
-
const result = (0, magic_router_js_1.getWritableAccounts)(transaction);
|
|
125
|
-
expect(result).toEqual(["fee-payer"]);
|
|
7
|
+
const mockPublicKey = (address) => ({
|
|
8
|
+
toBase58: () => address,
|
|
9
|
+
toString: () => address,
|
|
126
10
|
});
|
|
127
11
|
it("deduplicates writable accounts", () => {
|
|
128
|
-
const
|
|
12
|
+
const tx = {
|
|
129
13
|
feePayer: mockPublicKey("fee-payer"),
|
|
130
14
|
instructions: [
|
|
131
15
|
{
|
|
132
16
|
keys: [
|
|
133
|
-
{ pubkey: mockPublicKey("
|
|
134
|
-
{ pubkey: mockPublicKey("
|
|
135
|
-
{ pubkey: mockPublicKey("key2"), isWritable: false },
|
|
17
|
+
{ pubkey: mockPublicKey("k1"), isWritable: true },
|
|
18
|
+
{ pubkey: mockPublicKey("k1"), isWritable: true },
|
|
136
19
|
],
|
|
137
20
|
},
|
|
138
21
|
],
|
|
139
22
|
};
|
|
140
|
-
const result = (0, magic_router_js_1.getWritableAccounts)(
|
|
141
|
-
expect(result).toEqual(["fee-payer", "
|
|
23
|
+
const result = (0, magic_router_js_1.getWritableAccounts)(tx);
|
|
24
|
+
expect(result).toEqual(["fee-payer", "k1"]);
|
|
142
25
|
});
|
|
143
26
|
});
|
|
144
|
-
describe("
|
|
27
|
+
describe("Connection prototype methods", () => {
|
|
28
|
+
let connection;
|
|
29
|
+
let tx;
|
|
145
30
|
beforeEach(() => {
|
|
146
|
-
|
|
31
|
+
connection = new magic_router_js_1.ConnectionMagicRouter("http://localhost");
|
|
32
|
+
tx = new web3_js_1.Transaction();
|
|
33
|
+
tx.serialize = jest.fn(() => Buffer.from("mock"));
|
|
34
|
+
tx.sign = jest.fn();
|
|
35
|
+
global.fetch.mockReset();
|
|
147
36
|
});
|
|
148
|
-
it("
|
|
149
|
-
const mockIdentityData = {
|
|
150
|
-
result: {
|
|
151
|
-
identity: "mock-validator-identity",
|
|
152
|
-
},
|
|
153
|
-
};
|
|
37
|
+
it("getClosestValidator returns identity", async () => {
|
|
154
38
|
global.fetch.mockResolvedValueOnce({
|
|
155
|
-
json: async () =>
|
|
39
|
+
json: async () => ({ result: { identity: "validator-1" } }),
|
|
156
40
|
});
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
expect(global.fetch).toHaveBeenCalledWith("http://localhost", {
|
|
160
|
-
method: "POST",
|
|
161
|
-
headers: { "Content-Type": "application/json" },
|
|
162
|
-
body: JSON.stringify({
|
|
163
|
-
jsonrpc: "2.0",
|
|
164
|
-
id: 1,
|
|
165
|
-
method: "getIdentity",
|
|
166
|
-
params: [],
|
|
167
|
-
}),
|
|
168
|
-
});
|
|
169
|
-
expect(result.identity).toBe("mock-validator-identity");
|
|
170
|
-
});
|
|
171
|
-
it("handles fetch errors gracefully", async () => {
|
|
172
|
-
global.fetch.mockRejectedValueOnce(new Error("Network error"));
|
|
173
|
-
const connection = new web3_js_1.Connection("http://localhost");
|
|
174
|
-
await expect((0, magic_router_js_1.getClosestValidator)(connection)).rejects.toThrow("Network error");
|
|
41
|
+
const result = await connection.getClosestValidator();
|
|
42
|
+
expect(result).toEqual({ identity: "validator-1" });
|
|
175
43
|
});
|
|
176
|
-
it("
|
|
44
|
+
it("getDelegationStatus works with string account", async () => {
|
|
177
45
|
global.fetch.mockResolvedValueOnce({
|
|
178
|
-
json: async () =>
|
|
46
|
+
json: async () => ({ result: { isDelegated: true } }),
|
|
179
47
|
});
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe("getDelegationStatus", () => {
|
|
185
|
-
beforeEach(() => {
|
|
186
|
-
jest.clearAllMocks();
|
|
48
|
+
const result = await connection.getDelegationStatus("account1");
|
|
49
|
+
expect(result).toEqual({ isDelegated: true });
|
|
187
50
|
});
|
|
188
|
-
it("
|
|
51
|
+
it("getDelegationStatus works with PublicKey account", async () => {
|
|
189
52
|
global.fetch.mockResolvedValueOnce({
|
|
190
|
-
json: async () =>
|
|
191
|
-
});
|
|
192
|
-
const connection = new web3_js_1.Connection("http://localhost");
|
|
193
|
-
const account = "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU";
|
|
194
|
-
const result = await (0, magic_router_js_1.getDelegationStatus)(connection, account);
|
|
195
|
-
expect(global.fetch).toHaveBeenCalledWith("http://localhost/getDelegationStatus", {
|
|
196
|
-
method: "POST",
|
|
197
|
-
headers: { "Content-Type": "application/json" },
|
|
198
|
-
body: JSON.stringify({
|
|
199
|
-
jsonrpc: "2.0",
|
|
200
|
-
id: 1,
|
|
201
|
-
method: "getDelegationStatus",
|
|
202
|
-
params: [account],
|
|
203
|
-
}),
|
|
53
|
+
json: async () => ({ result: { isDelegated: false } }),
|
|
204
54
|
});
|
|
55
|
+
const pk = new web3_js_1.PublicKey("11111111111111111111111111111111");
|
|
56
|
+
const result = await connection.getDelegationStatus(pk);
|
|
205
57
|
expect(result).toEqual({ isDelegated: false });
|
|
206
58
|
});
|
|
207
|
-
it("returns
|
|
59
|
+
it("getLatestBlockhashForTransaction returns blockhash", async () => {
|
|
208
60
|
global.fetch.mockResolvedValueOnce({
|
|
209
|
-
json: async () =>
|
|
210
|
-
|
|
211
|
-
const connection = new web3_js_1.Connection("http://localhost");
|
|
212
|
-
const accountKey = new web3_js_1.PublicKey("mock-public-key");
|
|
213
|
-
const result = await (0, magic_router_js_1.getDelegationStatus)(connection, accountKey);
|
|
214
|
-
expect(global.fetch).toHaveBeenCalledWith("http://localhost/getDelegationStatus", {
|
|
215
|
-
method: "POST",
|
|
216
|
-
headers: { "Content-Type": "application/json" },
|
|
217
|
-
body: JSON.stringify({
|
|
218
|
-
jsonrpc: "2.0",
|
|
219
|
-
id: 1,
|
|
220
|
-
method: "getDelegationStatus",
|
|
221
|
-
params: [accountKey.toBase58()],
|
|
61
|
+
json: async () => ({
|
|
62
|
+
result: { blockhash: "mock-blockhash", lastValidBlockHeight: 100 },
|
|
222
63
|
}),
|
|
223
64
|
});
|
|
224
|
-
|
|
65
|
+
const result = await connection.getLatestBlockhashForTransaction(tx);
|
|
66
|
+
expect(result).toEqual({
|
|
67
|
+
blockhash: "mock-blockhash",
|
|
68
|
+
lastValidBlockHeight: 100,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it("prepareTransaction sets recentBlockhash", async () => {
|
|
72
|
+
jest
|
|
73
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "getLatestBlockhashForTransaction")
|
|
74
|
+
.mockResolvedValue({ blockhash: "hb", lastValidBlockHeight: 100 });
|
|
75
|
+
const result = await connection.prepareTransaction(tx);
|
|
76
|
+
expect(result.recentBlockhash).toBe("hb");
|
|
77
|
+
});
|
|
78
|
+
it("sendTransaction signs and sends transaction", async () => {
|
|
79
|
+
jest
|
|
80
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "getLatestBlockhashForTransaction")
|
|
81
|
+
.mockResolvedValue({ blockhash: "hb", lastValidBlockHeight: 100 });
|
|
82
|
+
jest
|
|
83
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "sendRawTransaction")
|
|
84
|
+
.mockResolvedValue("sig123");
|
|
85
|
+
const signers = [new web3_js_1.Keypair()];
|
|
86
|
+
const sendTx = connection.sendTransaction.bind(connection);
|
|
87
|
+
const signature = await sendTx(tx, signers);
|
|
88
|
+
const signFn = tx.sign.bind(tx);
|
|
89
|
+
const serializeFn = tx.serialize.bind(tx);
|
|
90
|
+
expect(signFn(...signers)).toBeUndefined();
|
|
91
|
+
expect(serializeFn()).toBeInstanceOf(Buffer);
|
|
92
|
+
expect(signature).toBe("sig123");
|
|
93
|
+
});
|
|
94
|
+
it("sendAndConfirmTransaction calls sendTransaction and returns signature", async () => {
|
|
95
|
+
jest
|
|
96
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "sendTransaction")
|
|
97
|
+
.mockResolvedValue("sig123");
|
|
98
|
+
jest
|
|
99
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "confirmTransaction")
|
|
100
|
+
.mockResolvedValue({ value: { err: null } });
|
|
101
|
+
const signature = await connection.sendAndConfirmTransaction(tx, [
|
|
102
|
+
new web3_js_1.Keypair(),
|
|
103
|
+
]);
|
|
104
|
+
expect(signature).toBe("sig123");
|
|
105
|
+
});
|
|
106
|
+
it("sendAndConfirmTransaction throws SendTransactionError if status has err", async () => {
|
|
107
|
+
jest
|
|
108
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "sendTransaction")
|
|
109
|
+
.mockResolvedValue("sig123");
|
|
110
|
+
jest
|
|
111
|
+
.spyOn(magic_router_js_1.ConnectionMagicRouter.prototype, "confirmTransaction")
|
|
112
|
+
.mockResolvedValue({ value: { err: { some: "error" } } });
|
|
113
|
+
await expect(connection.sendAndConfirmTransaction(tx, [new web3_js_1.Keypair()])).rejects.toThrow(web3_js_1.SendTransactionError);
|
|
225
114
|
});
|
|
226
115
|
});
|
|
227
116
|
//# sourceMappingURL=magic-router.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-router.test.js","sourceRoot":"","sources":["../../src/__tests__/magic-router.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"magic-router.test.js","sourceRoot":"","sources":["../../src/__tests__/magic-router.test.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAChF,6CAKyB;AAGzB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEzB,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,aAAa,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC;QAC1C,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO;QACvB,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO;KACxB,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,EAAE,GAAG;YACT,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC;YACpC,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE;wBACJ,EAAE,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EA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C1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/magic-router.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { Connection, Transaction, ConfirmOptions, TransactionSignature, Signer, BlockhashWithExpiryBlockHeight, SendOptions, PublicKey } from "@solana/web3.js";
|
|
1
|
+
import { Connection, Transaction, ConfirmOptions, TransactionSignature, Signer, BlockhashWithExpiryBlockHeight, SendOptions, PublicKey, VersionedTransaction } from "@solana/web3.js";
|
|
2
2
|
export declare function getWritableAccounts(transaction: Transaction): string[];
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
export declare class ConnectionMagicRouter extends Connection {
|
|
4
|
+
getClosestValidator(): Promise<{
|
|
5
|
+
identity: string;
|
|
6
|
+
fqdn?: string;
|
|
7
|
+
}>;
|
|
8
|
+
getDelegationStatus(account: PublicKey | string): Promise<{
|
|
9
|
+
isDelegated: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
getLatestBlockhashForTransaction(transaction: Transaction, options?: ConfirmOptions): Promise<BlockhashWithExpiryBlockHeight>;
|
|
12
|
+
prepareTransaction(transaction: Transaction, options?: ConfirmOptions): Promise<Transaction>;
|
|
13
|
+
sendTransaction(transaction: Transaction | VersionedTransaction, signersOrOptions?: Signer[] | SendOptions, options?: SendOptions): Promise<TransactionSignature>;
|
|
14
|
+
sendAndConfirmTransaction(transaction: Transaction, signers: Signer[], options?: ConfirmOptions & {
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
}): Promise<TransactionSignature>;
|
|
17
|
+
}
|
|
16
18
|
//# sourceMappingURL=magic-router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-router.d.ts","sourceRoot":"","sources":["../src/magic-router.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C"}
|
package/lib/magic-router.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionMagicRouter = void 0;
|
|
3
4
|
exports.getWritableAccounts = getWritableAccounts;
|
|
4
|
-
exports.getClosestValidator = getClosestValidator;
|
|
5
|
-
exports.getDelegationStatus = getDelegationStatus;
|
|
6
|
-
exports.getLatestBlockhashForMagicTransaction = getLatestBlockhashForMagicTransaction;
|
|
7
|
-
exports.prepareMagicTransaction = prepareMagicTransaction;
|
|
8
|
-
exports.sendMagicTransaction = sendMagicTransaction;
|
|
9
|
-
exports.sendAndConfirmMagicTransaction = sendAndConfirmMagicTransaction;
|
|
10
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
11
6
|
function getWritableAccounts(transaction) {
|
|
12
7
|
const writableAccounts = new Set();
|
|
@@ -22,113 +17,109 @@ function getWritableAccounts(transaction) {
|
|
|
22
17
|
}
|
|
23
18
|
return Array.from(writableAccounts);
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
class ConnectionMagicRouter extends web3_js_1.Connection {
|
|
21
|
+
async getClosestValidator() {
|
|
22
|
+
const response = await fetch(this.rpcEndpoint, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: { "Content-Type": "application/json" },
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
jsonrpc: "2.0",
|
|
27
|
+
id: 1,
|
|
28
|
+
method: "getIdentity",
|
|
29
|
+
params: [],
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
const identityData = (await response.json())?.result;
|
|
33
|
+
if (identityData === null || identityData.identity === undefined) {
|
|
34
|
+
throw new Error("Invalid response");
|
|
35
|
+
}
|
|
36
|
+
return identityData;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
const data = await response.json();
|
|
55
|
-
return data.result;
|
|
56
|
-
}
|
|
57
|
-
async function getLatestBlockhashForMagicTransaction(connection, transaction, options) {
|
|
58
|
-
const writableAccounts = getWritableAccounts(transaction);
|
|
59
|
-
const blockHashResponse = await fetch(connection.rpcEndpoint, {
|
|
60
|
-
method: "POST",
|
|
61
|
-
headers: { "Content-Type": "application/json" },
|
|
62
|
-
body: JSON.stringify({
|
|
63
|
-
jsonrpc: "2.0",
|
|
64
|
-
id: 1,
|
|
65
|
-
method: "getBlockhashForAccounts",
|
|
66
|
-
params: [writableAccounts],
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
const blockHashData = await blockHashResponse.json();
|
|
70
|
-
return blockHashData.result;
|
|
71
|
-
}
|
|
72
|
-
async function prepareMagicTransaction(connection, transaction, options) {
|
|
73
|
-
const blockHashData = await getLatestBlockhashForMagicTransaction(connection, transaction, options);
|
|
74
|
-
transaction.recentBlockhash = blockHashData.blockhash;
|
|
75
|
-
return transaction;
|
|
76
|
-
}
|
|
77
|
-
async function sendMagicTransaction(connection, transaction, signersOrOptions, options) {
|
|
78
|
-
const sendOpts = Array.isArray(signersOrOptions)
|
|
79
|
-
? (options ?? undefined)
|
|
80
|
-
: (signersOrOptions ?? undefined);
|
|
81
|
-
const latestBlockhash = await getLatestBlockhashForMagicTransaction(connection, transaction, sendOpts);
|
|
82
|
-
transaction.lastValidBlockHeight =
|
|
83
|
-
latestBlockhash.lastValidBlockHeight;
|
|
84
|
-
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
85
|
-
if (Array.isArray(signersOrOptions)) {
|
|
86
|
-
transaction.sign?.(...signersOrOptions);
|
|
38
|
+
async getDelegationStatus(account) {
|
|
39
|
+
const accountAddress = typeof account === "string" ? account : account.toBase58();
|
|
40
|
+
const response = await fetch(`${this.rpcEndpoint}/getDelegationStatus`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: { "Content-Type": "application/json" },
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
jsonrpc: "2.0",
|
|
45
|
+
id: 1,
|
|
46
|
+
method: "getDelegationStatus",
|
|
47
|
+
params: [accountAddress],
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
return (await response.json()).result;
|
|
87
51
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
52
|
+
async getLatestBlockhashForTransaction(transaction, options) {
|
|
53
|
+
const writableAccounts = getWritableAccounts(transaction);
|
|
54
|
+
const blockHashResponse = await fetch(this.rpcEndpoint, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
headers: { "Content-Type": "application/json" },
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
jsonrpc: "2.0",
|
|
59
|
+
id: 1,
|
|
60
|
+
method: "getBlockhashForAccounts",
|
|
61
|
+
params: [writableAccounts],
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
const blockHashData = await blockHashResponse.json();
|
|
65
|
+
return blockHashData.result;
|
|
102
66
|
}
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
abortSignal: options?.abortSignal,
|
|
108
|
-
minContextSlot: minNonceContextSlot,
|
|
109
|
-
nonceAccountPubkey,
|
|
110
|
-
nonceValue: nonceInfo.nonce,
|
|
111
|
-
signature,
|
|
112
|
-
}, options?.commitment)).value;
|
|
67
|
+
async prepareTransaction(transaction, options) {
|
|
68
|
+
const blockHashData = await this.getLatestBlockhashForTransaction(transaction, options);
|
|
69
|
+
transaction.recentBlockhash = blockHashData.blockhash;
|
|
70
|
+
return transaction;
|
|
113
71
|
}
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
72
|
+
async sendTransaction(transaction, signersOrOptions, options) {
|
|
73
|
+
if (transaction instanceof web3_js_1.Transaction) {
|
|
74
|
+
const latestBlockhash = await this.getLatestBlockhashForTransaction(transaction);
|
|
75
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
76
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
77
|
+
if (Array.isArray(signersOrOptions)) {
|
|
78
|
+
transaction.sign(...signersOrOptions);
|
|
79
|
+
}
|
|
80
|
+
const wireTx = transaction.serialize();
|
|
81
|
+
return this.sendRawTransaction(wireTx, options);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return super.sendTransaction(transaction, signersOrOptions);
|
|
119
85
|
}
|
|
120
|
-
status = (await connection.confirmTransaction(signature, options?.commitment)).value;
|
|
121
86
|
}
|
|
122
|
-
|
|
123
|
-
|
|
87
|
+
async sendAndConfirmTransaction(transaction, signers, options) {
|
|
88
|
+
const signature = await this.sendTransaction(transaction, signers, options);
|
|
89
|
+
let status;
|
|
90
|
+
const { recentBlockhash, lastValidBlockHeight, minNonceContextSlot, nonceInfo, } = transaction;
|
|
91
|
+
if (recentBlockhash !== undefined && lastValidBlockHeight !== undefined) {
|
|
92
|
+
status = (await this.confirmTransaction({
|
|
93
|
+
abortSignal: options?.abortSignal,
|
|
94
|
+
signature,
|
|
95
|
+
blockhash: recentBlockhash,
|
|
96
|
+
lastValidBlockHeight,
|
|
97
|
+
}, options?.commitment)).value;
|
|
98
|
+
}
|
|
99
|
+
else if (minNonceContextSlot !== undefined && nonceInfo !== undefined) {
|
|
100
|
+
const { nonceInstruction } = nonceInfo;
|
|
101
|
+
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
102
|
+
status = (await this.confirmTransaction({
|
|
103
|
+
abortSignal: options?.abortSignal,
|
|
104
|
+
minContextSlot: minNonceContextSlot,
|
|
105
|
+
nonceAccountPubkey,
|
|
106
|
+
nonceValue: nonceInfo.nonce,
|
|
107
|
+
signature,
|
|
108
|
+
}, options?.commitment)).value;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
status = (await this.confirmTransaction(signature, options?.commitment))
|
|
112
|
+
.value;
|
|
113
|
+
}
|
|
114
|
+
if (status.err != null) {
|
|
124
115
|
throw new web3_js_1.SendTransactionError({
|
|
125
116
|
action: "send",
|
|
126
117
|
signature,
|
|
127
118
|
transactionMessage: `Status: (${JSON.stringify(status)})`,
|
|
128
119
|
});
|
|
129
120
|
}
|
|
130
|
-
|
|
121
|
+
return signature;
|
|
131
122
|
}
|
|
132
|
-
return signature;
|
|
133
123
|
}
|
|
124
|
+
exports.ConnectionMagicRouter = ConnectionMagicRouter;
|
|
134
125
|
//# sourceMappingURL=magic-router.js.map
|
package/lib/magic-router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-router.js","sourceRoot":"","sources":["../src/magic-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"magic-router.js","sourceRoot":"","sources":["../src/magic-router.ts"],"names":[],"mappings":";;;AAkBA,kDAgBC;AAlCD,6CAWyB;AAOzB,SAAgB,mBAAmB,CAAC,WAAwB;IAC1D,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QACzB,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,MAAM,WAAW,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE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