@sentio/sdk 2.57.8-rc.1 → 2.57.8-rc.2

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.
@@ -3,7 +3,79 @@ import { FuelNetwork } from '../fuel/index.js';
3
3
  export declare class FuelFacet {
4
4
  server: TestProcessorServer;
5
5
  constructor(server: TestProcessorServer);
6
- testOnTransaction(transaction: any, network?: FuelNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
6
+ testOnTransaction(transaction: TestFuelTransaction, network?: FuelNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
7
+ testOnTransactionByID(network?: FuelNetwork, ...txIds: string[]): Promise<import("@sentio/protos").ProcessBindingResponse>;
7
8
  private buildBinding;
9
+ private gqlQuery;
8
10
  }
11
+ export interface TestFuelTransaction {
12
+ inputs?: Input[];
13
+ outputs?: Output[];
14
+ status?: Status;
15
+ rawPayload?: string;
16
+ }
17
+ interface Input {
18
+ utxoId: string;
19
+ balanceRoot?: string;
20
+ stateRoot?: string;
21
+ txPointer: string;
22
+ contractId?: string;
23
+ owner?: string;
24
+ amount?: string;
25
+ assetId?: string;
26
+ predicateGasUsed?: string;
27
+ predicate?: string;
28
+ predicateData?: string;
29
+ }
30
+ interface Output {
31
+ inputIndex?: string;
32
+ balanceRoot?: string;
33
+ stateRoot?: string;
34
+ to?: string;
35
+ amount?: string;
36
+ assetId?: string;
37
+ }
38
+ interface Status {
39
+ transactionId: string;
40
+ time: string;
41
+ totalGas: string;
42
+ totalFee: string;
43
+ block: Block;
44
+ receipts: Receipt[];
45
+ }
46
+ interface Block {
47
+ id: string;
48
+ height: string;
49
+ }
50
+ interface Receipt {
51
+ id?: string | null;
52
+ pc?: string | null;
53
+ is?: string | null;
54
+ to?: string | null;
55
+ toAddress?: string | null;
56
+ amount?: string | null;
57
+ assetId?: string | null;
58
+ gas?: string | null;
59
+ param1?: string | null;
60
+ param2?: string | null;
61
+ val?: string | null;
62
+ ptr?: string | null;
63
+ digest?: string | null;
64
+ reason?: string | null;
65
+ ra?: string | null;
66
+ rb?: string | null;
67
+ rc?: string | null;
68
+ rd?: string | null;
69
+ len?: string | null;
70
+ receiptType: string;
71
+ result?: string | null;
72
+ gasUsed?: string | null;
73
+ data?: string | null;
74
+ sender?: string | null;
75
+ recipient?: string | null;
76
+ nonce?: string | null;
77
+ contractId?: string | null;
78
+ subId?: string | null;
79
+ }
80
+ export {};
9
81
  //# sourceMappingURL=fuel-facet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fuel-facet.d.ts","sourceRoot":"","sources":["../../src/testing/fuel-facet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,qBAAa,SAAS;IACpB,MAAM,EAAE,mBAAmB,CAAA;gBAEf,MAAM,EAAE,mBAAmB;IAIvC,iBAAiB,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,GAAE,WAAkC;IAW/E,OAAO,CAAC,YAAY;CAoErB"}
1
+ {"version":3,"file":"fuel-facet.d.ts","sourceRoot":"","sources":["../../src/testing/fuel-facet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,qBAAa,SAAS;IACpB,MAAM,EAAE,mBAAmB,CAAA;gBAEf,MAAM,EAAE,mBAAmB;IAIvC,iBAAiB,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,GAAE,WAAkC;IAczF,qBAAqB,CAAC,OAAO,GAAE,WAAkC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE;IAe3F,OAAO,CAAC,YAAY;YAqEN,QAAQ;CAmBvB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,OAAO,CAAC,EAA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
3
+ import { getRpcEndpoint } from '../fuel/network.js';
3
4
  export class FuelFacet {
4
5
  server;
5
6
  constructor(server) {
@@ -14,6 +15,21 @@ export class FuelFacet {
14
15
  bindings
15
16
  });
16
17
  }
18
+ /*
19
+ * Test on transactions by downloading them from the network
20
+ */
21
+ async testOnTransactionByID(network = FuelNetwork.TEST_NET, ...txIds) {
22
+ const url = getRpcEndpoint(network);
23
+ const allBindings = [];
24
+ for (const txId of txIds) {
25
+ const tx = await this.gqlQuery(url, txId);
26
+ const bindings = this.buildBinding(tx, network);
27
+ allBindings.push(...bindings);
28
+ }
29
+ return this.server.processBindings({
30
+ bindings: allBindings
31
+ });
32
+ }
17
33
  buildBinding(transaction, network) {
18
34
  const res = [];
19
35
  for (const config of this.server.contractConfigs) {
@@ -76,5 +92,152 @@ export class FuelFacet {
76
92
  }
77
93
  return res;
78
94
  }
95
+ async gqlQuery(url, txId) {
96
+ const res = await fetch(url, {
97
+ body: JSON.stringify({
98
+ query: GetTransactionQuery,
99
+ variables: {
100
+ id: txId
101
+ }
102
+ }),
103
+ headers: {
104
+ 'Content-Type': 'application/json'
105
+ },
106
+ method: 'POST'
107
+ });
108
+ if (!res.ok) {
109
+ throw Error('Failed to fetch transaction: ' + res.statusText);
110
+ }
111
+ const json = (await res.json());
112
+ return json.data.transaction;
113
+ }
79
114
  }
115
+ const GetTransactionQuery = `
116
+ query GetTransaction($id: TransactionId!) {
117
+ transaction(id: $id) {
118
+ id
119
+ rawPayload
120
+ status {
121
+ type: __typename
122
+ ... on SuccessStatus {
123
+ block {
124
+ id
125
+ header {
126
+ height
127
+ }
128
+ }
129
+ time
130
+ programState {
131
+ returnType
132
+ data
133
+ }
134
+ blockHeight
135
+ transactionId
136
+ totalGas
137
+ totalFee
138
+ receipts {
139
+ id
140
+ pc
141
+ is
142
+ to
143
+ toAddress
144
+ amount
145
+ assetId
146
+ gas
147
+ param1
148
+ param2
149
+ val
150
+ ptr
151
+ digest
152
+ reason
153
+ ra
154
+ rb
155
+ rc
156
+ rd
157
+ len
158
+ receiptType
159
+ result
160
+ gasUsed
161
+ data
162
+ sender
163
+ recipient
164
+ nonce
165
+ contractId
166
+ subId
167
+ }
168
+ }
169
+ ... on SubmittedStatus {
170
+ time
171
+ }
172
+ ... on SqueezedOutStatus {
173
+ reason
174
+ }
175
+ ... on FailureStatus {
176
+ transactionId
177
+ blockHeight
178
+ time
179
+ reason
180
+ totalGas
181
+ totalFee
182
+ }
183
+ }
184
+ inputs {
185
+ ... on InputCoin {
186
+ utxoId
187
+ owner
188
+ amount
189
+ assetId
190
+ txPointer
191
+ witnessIndex
192
+ predicateGasUsed
193
+ predicate
194
+ predicateData
195
+ }
196
+ ... on InputContract {
197
+ utxoId
198
+ balanceRoot
199
+ stateRoot
200
+ txPointer
201
+ contractId
202
+ }
203
+ ... on InputMessage {
204
+ sender
205
+ recipient
206
+ amount
207
+ nonce
208
+ predicateGasUsed
209
+ data
210
+ predicate
211
+ predicateData
212
+ }
213
+ }
214
+ outputs {
215
+ ... on ContractCreated {
216
+ contract
217
+ stateRoot
218
+ }
219
+ ... on VariableOutput {
220
+ to
221
+ amount
222
+ assetId
223
+ }
224
+ ... on ChangeOutput {
225
+ to
226
+ amount
227
+ assetId
228
+ }
229
+ ... on ContractOutput {
230
+ inputIndex
231
+ balanceRoot
232
+ stateRoot
233
+ }
234
+ ... on CoinOutput {
235
+ to
236
+ amount
237
+ assetId
238
+ }
239
+ }
240
+ receiptsRoot
241
+ }
242
+ }`;
80
243
  //# sourceMappingURL=fuel-facet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fuel-facet.js","sourceRoot":"","sources":["../../src/testing/fuel-facet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,MAAM,OAAO,SAAS;IACpB,MAAM,CAAqB;IAE3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM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AC,IAAI,EAAE,CAAQ,CAAA;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAkC,CAAA;IACrD,CAAC;CACF;AA6ED,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+H1B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.57.8-rc.1",
3
+ "version": "2.57.8-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -86,8 +86,8 @@
86
86
  "typechain": "^8.3.2",
87
87
  "utility-types": "^3.11.0",
88
88
  "yaml": "^2.3.4",
89
- "@sentio/runtime": "^2.57.8-rc.1",
90
- "@sentio/protos": "2.57.8-rc.1"
89
+ "@sentio/protos": "2.57.8-rc.2",
90
+ "@sentio/runtime": "^2.57.8-rc.2"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "tsup": "npm:@sentio/tsup@^8.3.5-rc.1"
@@ -2,6 +2,7 @@ import { TestProcessorServer } from './test-processor-server.js'
2
2
  import { FuelChainId } from '@sentio/chain'
3
3
  import { DataBinding, HandlerType } from '@sentio/protos'
4
4
  import { FuelNetwork } from '../fuel/index.js'
5
+ import { getRpcEndpoint } from '../fuel/network.js'
5
6
 
6
7
  export class FuelFacet {
7
8
  server: TestProcessorServer
@@ -10,7 +11,7 @@ export class FuelFacet {
10
11
  this.server = server
11
12
  }
12
13
 
13
- testOnTransaction(transaction: any, network: FuelNetwork = FuelNetwork.TEST_NET) {
14
+ testOnTransaction(transaction: TestFuelTransaction, network: FuelNetwork = FuelNetwork.TEST_NET) {
14
15
  const bindings = this.buildBinding(transaction, network)
15
16
  if (!bindings) {
16
17
  throw Error('Invalid test transaction: ' + JSON.stringify(transaction))
@@ -21,6 +22,24 @@ export class FuelFacet {
21
22
  })
22
23
  }
23
24
 
25
+ /*
26
+ * Test on transactions by downloading them from the network
27
+ */
28
+ async testOnTransactionByID(network: FuelNetwork = FuelNetwork.TEST_NET, ...txIds: string[]) {
29
+ const url = getRpcEndpoint(network)
30
+
31
+ const allBindings: DataBinding[] = []
32
+ for (const txId of txIds) {
33
+ const tx = await this.gqlQuery(url, txId)
34
+
35
+ const bindings = this.buildBinding(tx, network)
36
+ allBindings.push(...bindings)
37
+ }
38
+ return this.server.processBindings({
39
+ bindings: allBindings
40
+ })
41
+ }
42
+
24
43
  private buildBinding(transaction: any, network: FuelChainId): DataBinding[] {
25
44
  const res: DataBinding[] = []
26
45
  for (const config of this.server.contractConfigs) {
@@ -89,4 +108,228 @@ export class FuelFacet {
89
108
 
90
109
  return res
91
110
  }
111
+
112
+ private async gqlQuery(url: string, txId: string) {
113
+ const res = await fetch(url, {
114
+ body: JSON.stringify({
115
+ query: GetTransactionQuery,
116
+ variables: {
117
+ id: txId
118
+ }
119
+ }),
120
+ headers: {
121
+ 'Content-Type': 'application/json'
122
+ },
123
+ method: 'POST'
124
+ })
125
+ if (!res.ok) {
126
+ throw Error('Failed to fetch transaction: ' + res.statusText)
127
+ }
128
+ const json = (await res.json()) as any
129
+ return json.data.transaction as TestFuelTransaction
130
+ }
131
+ }
132
+
133
+ export interface TestFuelTransaction {
134
+ inputs?: Input[]
135
+ outputs?: Output[]
136
+ status?: Status
137
+ rawPayload?: string
138
+ }
139
+
140
+ interface Input {
141
+ utxoId: string
142
+ balanceRoot?: string
143
+ stateRoot?: string
144
+ txPointer: string
145
+ contractId?: string
146
+ owner?: string
147
+ amount?: string
148
+ assetId?: string
149
+ predicateGasUsed?: string
150
+ predicate?: string
151
+ predicateData?: string
152
+ }
153
+
154
+ interface Output {
155
+ inputIndex?: string
156
+ balanceRoot?: string
157
+ stateRoot?: string
158
+ to?: string
159
+ amount?: string
160
+ assetId?: string
161
+ }
162
+
163
+ interface Status {
164
+ transactionId: string
165
+ time: string
166
+ totalGas: string
167
+ totalFee: string
168
+ block: Block
169
+ receipts: Receipt[]
170
+ }
171
+
172
+ interface Block {
173
+ id: string
174
+ height: string
92
175
  }
176
+
177
+ interface Receipt {
178
+ id?: string | null
179
+ pc?: string | null
180
+ is?: string | null
181
+ to?: string | null
182
+ toAddress?: string | null
183
+ amount?: string | null
184
+ assetId?: string | null
185
+ gas?: string | null
186
+ param1?: string | null
187
+ param2?: string | null
188
+ val?: string | null
189
+ ptr?: string | null
190
+ digest?: string | null
191
+ reason?: string | null
192
+ ra?: string | null
193
+ rb?: string | null
194
+ rc?: string | null
195
+ rd?: string | null
196
+ len?: string | null
197
+ receiptType: string
198
+ result?: string | null
199
+ gasUsed?: string | null
200
+ data?: string | null
201
+ sender?: string | null
202
+ recipient?: string | null
203
+ nonce?: string | null
204
+ contractId?: string | null
205
+ subId?: string | null
206
+ }
207
+
208
+ const GetTransactionQuery = `
209
+ query GetTransaction($id: TransactionId!) {
210
+ transaction(id: $id) {
211
+ id
212
+ rawPayload
213
+ status {
214
+ type: __typename
215
+ ... on SuccessStatus {
216
+ block {
217
+ id
218
+ header {
219
+ height
220
+ }
221
+ }
222
+ time
223
+ programState {
224
+ returnType
225
+ data
226
+ }
227
+ blockHeight
228
+ transactionId
229
+ totalGas
230
+ totalFee
231
+ receipts {
232
+ id
233
+ pc
234
+ is
235
+ to
236
+ toAddress
237
+ amount
238
+ assetId
239
+ gas
240
+ param1
241
+ param2
242
+ val
243
+ ptr
244
+ digest
245
+ reason
246
+ ra
247
+ rb
248
+ rc
249
+ rd
250
+ len
251
+ receiptType
252
+ result
253
+ gasUsed
254
+ data
255
+ sender
256
+ recipient
257
+ nonce
258
+ contractId
259
+ subId
260
+ }
261
+ }
262
+ ... on SubmittedStatus {
263
+ time
264
+ }
265
+ ... on SqueezedOutStatus {
266
+ reason
267
+ }
268
+ ... on FailureStatus {
269
+ transactionId
270
+ blockHeight
271
+ time
272
+ reason
273
+ totalGas
274
+ totalFee
275
+ }
276
+ }
277
+ inputs {
278
+ ... on InputCoin {
279
+ utxoId
280
+ owner
281
+ amount
282
+ assetId
283
+ txPointer
284
+ witnessIndex
285
+ predicateGasUsed
286
+ predicate
287
+ predicateData
288
+ }
289
+ ... on InputContract {
290
+ utxoId
291
+ balanceRoot
292
+ stateRoot
293
+ txPointer
294
+ contractId
295
+ }
296
+ ... on InputMessage {
297
+ sender
298
+ recipient
299
+ amount
300
+ nonce
301
+ predicateGasUsed
302
+ data
303
+ predicate
304
+ predicateData
305
+ }
306
+ }
307
+ outputs {
308
+ ... on ContractCreated {
309
+ contract
310
+ stateRoot
311
+ }
312
+ ... on VariableOutput {
313
+ to
314
+ amount
315
+ assetId
316
+ }
317
+ ... on ChangeOutput {
318
+ to
319
+ amount
320
+ assetId
321
+ }
322
+ ... on ContractOutput {
323
+ inputIndex
324
+ balanceRoot
325
+ stateRoot
326
+ }
327
+ ... on CoinOutput {
328
+ to
329
+ amount
330
+ assetId
331
+ }
332
+ }
333
+ receiptsRoot
334
+ }
335
+ }`