@ar.io/sdk 1.2.1 → 2.0.0-alpha.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.
Files changed (51) hide show
  1. package/README.md +5 -1
  2. package/bundles/web.bundle.min.js +132 -331
  3. package/lib/cjs/common/ant.js +1 -351
  4. package/lib/cjs/common/index.js +0 -4
  5. package/lib/cjs/common/io.js +1 -1
  6. package/lib/cjs/common/logger.js +27 -15
  7. package/lib/cjs/types.js +0 -1
  8. package/lib/cjs/utils/arweave.js +1 -15
  9. package/lib/cjs/utils/graphql/index.js +0 -1
  10. package/lib/cjs/utils/index.js +0 -1
  11. package/lib/cjs/version.js +1 -1
  12. package/lib/esm/common/ant.js +2 -350
  13. package/lib/esm/common/index.js +0 -4
  14. package/lib/esm/common/io.js +1 -1
  15. package/lib/esm/common/logger.js +27 -12
  16. package/lib/esm/types.js +0 -1
  17. package/lib/esm/utils/arweave.js +0 -12
  18. package/lib/esm/utils/graphql/index.js +0 -1
  19. package/lib/esm/utils/index.js +0 -1
  20. package/lib/esm/version.js +1 -1
  21. package/lib/types/common/ant.d.ts +1 -274
  22. package/lib/types/common/index.d.ts +0 -3
  23. package/lib/types/common/logger.d.ts +2 -2
  24. package/lib/types/common.d.ts +1 -138
  25. package/lib/types/types.d.ts +0 -1
  26. package/lib/types/utils/arweave.d.ts +0 -5
  27. package/lib/types/utils/graphql/index.d.ts +0 -1
  28. package/lib/types/utils/index.d.ts +0 -1
  29. package/lib/types/version.d.ts +1 -1
  30. package/package.json +5 -10
  31. package/lib/cjs/arns-service.js +0 -2
  32. package/lib/cjs/common/ar-io.js +0 -741
  33. package/lib/cjs/common/contracts/remote-contract.js +0 -55
  34. package/lib/cjs/common/contracts/warp-contract.js +0 -176
  35. package/lib/cjs/common/warp.js +0 -25
  36. package/lib/cjs/utils/graphql/smartweave.js +0 -309
  37. package/lib/cjs/utils/smartweave.js +0 -58
  38. package/lib/esm/arns-service.js +0 -1
  39. package/lib/esm/common/ar-io.js +0 -735
  40. package/lib/esm/common/contracts/remote-contract.js +0 -51
  41. package/lib/esm/common/contracts/warp-contract.js +0 -172
  42. package/lib/esm/common/warp.js +0 -22
  43. package/lib/esm/utils/graphql/smartweave.js +0 -303
  44. package/lib/esm/utils/smartweave.js +0 -50
  45. package/lib/types/arns-service.d.ts +0 -23
  46. package/lib/types/common/ar-io.d.ts +0 -551
  47. package/lib/types/common/contracts/remote-contract.d.ts +0 -38
  48. package/lib/types/common/contracts/warp-contract.d.ts +0 -43
  49. package/lib/types/common/warp.d.ts +0 -1
  50. package/lib/types/utils/graphql/smartweave.d.ts +0 -47
  51. package/lib/types/utils/smartweave.d.ts +0 -41
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteContract = void 0;
4
- const http_js_1 = require("../http.js");
5
- const logger_js_1 = require("../logger.js");
6
- // TODO: this assumes the API structure matches the current arns-service API - we will want to consider another interface that exposes relevant APIs with client implementations (arns-service, DRE nodes, etc.)
7
- class RemoteContract {
8
- logger;
9
- http;
10
- contractTxId;
11
- cacheUrl;
12
- constructor({ cacheUrl = 'https://api.arns.app', contractTxId, logger = new logger_js_1.DefaultLogger(), }) {
13
- this.cacheUrl = cacheUrl;
14
- this.contractTxId = contractTxId;
15
- this.logger = logger;
16
- this.http = new http_js_1.AxiosHTTPService({
17
- url: `${cacheUrl}/v1/contract/${contractTxId}`,
18
- });
19
- }
20
- configuration() {
21
- return {
22
- contractTxId: this.contractTxId,
23
- cacheUrl: this.cacheUrl,
24
- };
25
- }
26
- async getState({ evaluationOptions } = {}) {
27
- this.logger.debug(`Fetching contract state`, {
28
- contractTxId: this.contractTxId,
29
- evaluationOptions,
30
- });
31
- const { state } = await this.http.get({
32
- endpoint: ``,
33
- params: {
34
- ...evaluationOptions?.evalTo,
35
- },
36
- });
37
- return state;
38
- }
39
- async readInteraction({ functionName, inputs, evaluationOptions, }) {
40
- this.logger.debug(`Evaluating read interaction on contract`, {
41
- functionName,
42
- inputs,
43
- evaluationOptions,
44
- });
45
- const { result } = await this.http.get({
46
- endpoint: `/read/${functionName}`,
47
- params: {
48
- ...evaluationOptions?.evalTo,
49
- ...inputs,
50
- },
51
- });
52
- return result;
53
- }
54
- }
55
- exports.RemoteContract = RemoteContract;
@@ -1,176 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WarpContract = void 0;
4
- /**
5
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Affero General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Affero General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Affero General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- */
20
- const warp_contracts_1 = require("warp-contracts");
21
- const base64_js_1 = require("../../utils/base64.js");
22
- const smartweave_js_1 = require("../../utils/smartweave.js");
23
- const error_js_1 = require("../error.js");
24
- const logger_js_1 = require("../logger.js");
25
- const warp_js_1 = require("../warp.js");
26
- warp_contracts_1.LoggerFactory.INST.logLevel('error');
27
- class WarpContract {
28
- contract;
29
- contractTxId;
30
- cacheUrl;
31
- logger;
32
- warp;
33
- constructor({ contractTxId, cacheUrl = 'https://api.arns.app', warp = warp_js_1.defaultWarp, logger = new logger_js_1.DefaultLogger({
34
- level: 'info',
35
- }), }) {
36
- this.contractTxId = contractTxId;
37
- this.contract = warp.contract(contractTxId);
38
- this.cacheUrl = cacheUrl;
39
- this.warp = warp;
40
- this.logger = logger;
41
- }
42
- configuration() {
43
- return {
44
- contractTxId: this.contractTxId,
45
- cacheUrl: this.cacheUrl,
46
- };
47
- }
48
- // TODO: could abstract into our own interface that constructs different signers
49
- async createWarpSigner(signer) {
50
- // ensure appropriate permissions are granted with injected signers.
51
- if (signer.publicKey === undefined && 'setPublicKey' in signer) {
52
- await signer.setPublicKey();
53
- }
54
- const warpSigner = new warp_contracts_1.Signature(this.warp, {
55
- signer: async (tx) => {
56
- tx.setOwner((0, base64_js_1.toB64Url)(signer.publicKey));
57
- const dataToSign = await tx.getSignatureData();
58
- const signatureUint8Array = await signer.sign(dataToSign);
59
- const signatureBuffer = Buffer.from(signatureUint8Array);
60
- const id = (0, base64_js_1.sha256B64Url)(signatureBuffer);
61
- tx.setSignature({
62
- id: id,
63
- owner: (0, base64_js_1.toB64Url)(signer.publicKey),
64
- signature: (0, base64_js_1.toB64Url)(signatureBuffer),
65
- });
66
- },
67
- type: 'arweave',
68
- });
69
- return warpSigner;
70
- }
71
- async getState({ evaluationOptions = {} }) {
72
- await this.ensureContractInit();
73
- const evalTo = evaluationOptions?.evalTo;
74
- let sortKeyOrBlockHeight;
75
- if (evalTo && 'sortKey' in evalTo) {
76
- sortKeyOrBlockHeight = evalTo.sortKey;
77
- }
78
- else if (evalTo && 'blockHeight' in evalTo) {
79
- sortKeyOrBlockHeight = evalTo.blockHeight;
80
- }
81
- const evaluationResult = await this.contract.readState(sortKeyOrBlockHeight);
82
- if (!evaluationResult.cachedValue.state) {
83
- throw new error_js_1.FailedRequestError(502, 'Failed to evaluate contract state');
84
- }
85
- return evaluationResult.cachedValue.state;
86
- }
87
- async ensureContractInit({ signer } = {}) {
88
- this.logger.debug(`Checking contract initialized`, {
89
- contractTxId: this.contractTxId,
90
- });
91
- // Get contact manifest and sync state
92
- this.logger.debug(`Fetching contract manifest`, {
93
- contractTxId: this.contractTxId,
94
- });
95
- const { evaluationOptions = {} } = await (0, smartweave_js_1.getContractManifest)({
96
- arweave: this.warp.arweave,
97
- contractTxId: this.contractTxId,
98
- });
99
- this.contract.setEvaluationOptions(evaluationOptions);
100
- if (signer)
101
- this.contract.connect(await this.createWarpSigner(signer));
102
- if (this.cacheUrl !== undefined) {
103
- this.logger.debug(`Syncing contract state`, {
104
- contractTxId: this.contractTxId,
105
- remoteCacheUrl: this.cacheUrl,
106
- });
107
- await this.contract.syncState(`${this.cacheUrl}/v1/contract/${this.contractTxId}`, {
108
- validity: true,
109
- });
110
- }
111
- }
112
- async readInteraction({ functionName, inputs,
113
- // TODO: view state only supports sort key so we won't be able to use block height
114
- }) {
115
- await this.ensureContractInit();
116
- this.logger.debug(`Read interaction: ${functionName}`, {
117
- contractTxId: this.contractTxId,
118
- inputs,
119
- });
120
- const evaluationResult = await this.contract.viewState({
121
- function: functionName,
122
- ...inputs,
123
- });
124
- if (evaluationResult.result === undefined) {
125
- throw new error_js_1.FailedRequestError(502, 'Failed to evaluate contract read interaction: ' +
126
- JSON.stringify({ error: evaluationResult.errorMessage, functionName, inputs }, null, 2));
127
- }
128
- this.logger.debug('Successfully evaluated contract read interaction', {
129
- contractTxId: this.contractTxId,
130
- result: evaluationResult.result,
131
- });
132
- return evaluationResult.result;
133
- }
134
- async writeInteraction({ functionName, inputs, signer,
135
- // TODO: support dryWrite
136
- }, options) {
137
- try {
138
- this.logger.debug(`Write interaction: ${functionName}`, {
139
- contractTxId: this.contractTxId,
140
- });
141
- // Sync state before writing
142
- await this.ensureContractInit({ signer });
143
- // run dry write before actual write
144
- const result = await this.contract.dryWrite({
145
- function: functionName,
146
- ...inputs,
147
- });
148
- if (result.type !== 'ok') {
149
- throw new Error(`Failed to dry write contract interaction ${functionName}: ${result.errorMessage}`);
150
- }
151
- const writeResult = await this.contract.writeInteraction({
152
- function: functionName,
153
- ...inputs,
154
- }, {
155
- disableBundling: true,
156
- tags: options?.tags?.map((tag) => new warp_contracts_1.Tag(tag.name, tag.value)),
157
- });
158
- if (!writeResult?.interactionTx) {
159
- throw new Error(`Failed to write contract interaction: ${functionName}`);
160
- }
161
- this.logger.debug('Successfully wrote contract interaction', {
162
- contractTxId: this.contractTxId,
163
- interactionTxId: writeResult.originalTxId,
164
- });
165
- // hack - we only support L1 for interactions so they should always be transactions
166
- return writeResult.interactionTx;
167
- }
168
- catch (error) {
169
- this.logger.error(`Failed to write contract interaction: ${error.message}`, {
170
- contractTxId: this.contractTxId,
171
- });
172
- throw new error_js_1.WriteInteractionError(error);
173
- }
174
- }
175
- }
176
- exports.WarpContract = WarpContract;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultWarp = void 0;
4
- /**
5
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Affero General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Affero General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Affero General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- */
20
- const warp_contracts_1 = require("warp-contracts");
21
- const arweave_js_1 = require("./arweave.js");
22
- exports.defaultWarp = warp_contracts_1.WarpFactory.forMainnet({
23
- ...warp_contracts_1.defaultCacheOptions,
24
- inMemory: true,
25
- }, true, arweave_js_1.defaultArweave);
@@ -1,309 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContractsTransferredToOrControlledByWallet = exports.getSmartweaveTransactionsFromGQL = exports.getSmartweaveContractsFromGQL = exports.MAX_REQUEST_SIZE = void 0;
4
- const error_js_1 = require("../../common/error.js");
5
- exports.MAX_REQUEST_SIZE = 100;
6
- /**
7
- * @param arweave - arweave instance to perform gql request
8
- * @param address - address of the wallet to get transactions for
9
- * @param signal - signal to abort the request
10
- * @returns @type {Promise<DataProtocolTransaction[]>} - returns the list of data protocol txs, for e.g smartweave contracts
11
- */
12
- async function getSmartweaveContractsFromGQL({ address, arweave, signal = AbortSignal.timeout(10_000),
13
- // TODO: add retry provider - eg pass in fetcher for the query
14
- }) {
15
- let hasNextPage = false;
16
- let cursor;
17
- const protocolTxs = new Set();
18
- do {
19
- const queryObject = {
20
- query: `
21
- {
22
- transactions (
23
- owners:["${address}"]
24
- tags: [
25
- {
26
- name: "App-Name",
27
- values: ["SmartWeaveContract"],
28
- },
29
- ],
30
- sort: HEIGHT_DESC,
31
- first: ${exports.MAX_REQUEST_SIZE},
32
- bundledIn: null,
33
- ${cursor !== undefined ? `after: "${cursor}"` : ''}
34
- ) {
35
- pageInfo {
36
- hasNextPage
37
- }
38
- edges {
39
- cursor
40
- node {
41
- id
42
- block {
43
- height
44
- }
45
- tags {
46
- name
47
- value
48
- }
49
- }
50
- }
51
- }
52
- }`,
53
- };
54
- if (signal?.aborted) {
55
- throw new error_js_1.AbortError('GraphQL request was aborted.');
56
- }
57
- const { status, ...response } = await arweave.api.post('/graphql', queryObject, {
58
- signal,
59
- });
60
- if (status == 429) {
61
- await new Promise((resolve) => setTimeout(resolve, 10_000));
62
- continue;
63
- }
64
- if (status !== 200) {
65
- console.dir(response, { depth: null });
66
- throw Error(`Failed to fetch contracts for wallet. Status code: ${status}`);
67
- }
68
- if (!response.data.data?.transactions?.edges?.length) {
69
- continue;
70
- }
71
- response.data.data.transactions.edges
72
- .map((e) => ({
73
- id: e.node.id,
74
- tags: e.node.tags,
75
- data: e.node.data,
76
- }))
77
- .forEach((c) => {
78
- protocolTxs.add(c.def);
79
- });
80
- cursor =
81
- response.data.data.transactions.edges[exports.MAX_REQUEST_SIZE - 1]?.cursor;
82
- hasNextPage =
83
- response.data.data.transactions.pageInfo?.hasNextPage ?? false;
84
- } while (hasNextPage);
85
- return [...protocolTxs];
86
- }
87
- exports.getSmartweaveContractsFromGQL = getSmartweaveContractsFromGQL;
88
- /**
89
- * @param arweave - arweave instance to perform gql request
90
- * @param address - address of the wallet to get transactions for
91
- * @param contractTxId - contract tx id to filter the transactions
92
- * @param signal - signal to abort the request
93
- * @returns @type {Promise<DataProtocolTransaction[]>} - returns the list of data protocol txs, for e.g smartweave contracts
94
- */
95
- async function getSmartweaveTransactionsFromGQL({ address, contractTxId, arweave, signal = AbortSignal.timeout(10_000),
96
- // TODO: add retry provider - eg pass in fetcher for the query
97
- }) {
98
- let hasNextPage = false;
99
- let cursor;
100
- const protocolTxs = new Set();
101
- do {
102
- const queryObject = {
103
- query: `
104
- {
105
- transactions (
106
- owners:["${address}"]
107
- tags: [
108
- {
109
- name: "App-Name",
110
- values: ["SmartWeaveAction"],
111
- },
112
- {
113
- name: "Contract",
114
- values: ["${contractTxId}"],
115
- },
116
- ],
117
- sort: HEIGHT_DESC,
118
- first: ${exports.MAX_REQUEST_SIZE},
119
- bundledIn: null,
120
- ${cursor !== undefined ? `after: "${cursor}"` : ''}
121
- ) {
122
- pageInfo {
123
- hasNextPage
124
- }
125
- edges {
126
- cursor
127
- node {
128
- id
129
- block {
130
- height
131
- }
132
- tags {
133
- name
134
- value
135
- }
136
- }
137
- }
138
- }
139
- }`,
140
- };
141
- if (signal?.aborted) {
142
- throw new error_js_1.AbortError('GraphQL request was aborted.');
143
- }
144
- const { status, ...response } = await arweave.api.post('/graphql', queryObject, {
145
- signal,
146
- });
147
- if (status == 429) {
148
- await new Promise((resolve) => setTimeout(resolve, 10_000));
149
- continue;
150
- }
151
- if (status !== 200) {
152
- throw Error(`Failed to fetch contracts for wallet. Status code: ${status}`);
153
- }
154
- if (!response.data.data?.transactions?.edges?.length) {
155
- continue;
156
- }
157
- response.data.data.transactions.edges
158
- .map((e) => ({
159
- id: e.node.id,
160
- tags: e.node.tags,
161
- data: e.node.data,
162
- }))
163
- .forEach((c) => {
164
- protocolTxs.add(c.def);
165
- });
166
- cursor =
167
- response.data.data.transactions.edges[exports.MAX_REQUEST_SIZE - 1]?.cursor;
168
- hasNextPage =
169
- response.data.data.transactions.pageInfo?.hasNextPage ?? false;
170
- } while (hasNextPage);
171
- return [...protocolTxs];
172
- }
173
- exports.getSmartweaveTransactionsFromGQL = getSmartweaveTransactionsFromGQL;
174
- async function getContractsTransferredToOrControlledByWallet(arweave, params, signal) {
175
- const { address } = params;
176
- let hasNextPage = false;
177
- let cursor;
178
- const protocolTxs = new Set();
179
- do {
180
- const queryObject = {
181
- query: `
182
- {
183
- transactions (
184
- tags:[
185
- {
186
- name: "App-Name",
187
- values: ["SmartWeaveAction"]
188
- },
189
- {
190
- name: "Input",
191
- values: ${JSON.stringify([
192
- // duplicated because the order of the input matters when querying gql
193
- {
194
- function: 'setController',
195
- target: address,
196
- },
197
- {
198
- target: address,
199
- function: 'setController',
200
- },
201
- {
202
- function: 'transfer',
203
- target: address,
204
- qty: 1,
205
- },
206
- {
207
- function: 'transfer',
208
- qty: 1,
209
- target: address,
210
- },
211
- {
212
- target: address,
213
- function: 'transfer',
214
- qty: 1,
215
- },
216
- {
217
- target: address,
218
- qty: 1,
219
- function: 'transfer',
220
- },
221
- {
222
- qty: 1,
223
- target: address,
224
- function: 'transfer',
225
- },
226
- {
227
- qty: 1,
228
- function: 'transfer',
229
- target: address,
230
- },
231
- // removing qty just for coverage
232
- {
233
- function: 'transfer',
234
- target: address,
235
- },
236
- {
237
- target: address,
238
- function: 'transfer',
239
- },
240
- ])
241
- .replace(/"/g, '\\"')
242
- .replace(/\{/g, '"{')
243
- .replace(/\}/g, '}"')}
244
- }
245
- ],
246
- sort: HEIGHT_DESC,
247
- first: ${exports.MAX_REQUEST_SIZE},
248
- bundledIn: null,
249
- ${cursor !== undefined ? `after: "${cursor}"` : ''}
250
- ) {
251
- pageInfo {
252
- hasNextPage
253
- }
254
- edges {
255
- cursor
256
- node {
257
- id
258
- tags {
259
- name
260
- value
261
- }
262
- block {
263
- height
264
- }
265
- }
266
- }
267
- }
268
- }`,
269
- };
270
- if (signal?.aborted) {
271
- throw new error_js_1.AbortError('GraphQL request was aborted.');
272
- }
273
- const { status, ...response } = await arweave.api.post('/graphql', queryObject, {
274
- signal,
275
- });
276
- if (status == 429) {
277
- await new Promise((resolve) => setTimeout(resolve, 10_000));
278
- continue;
279
- }
280
- if (status !== 200) {
281
- throw Error(`Failed to fetch contracts for wallet. Status code: ${status}`);
282
- }
283
- if (!response.data.data?.transactions?.edges?.length) {
284
- continue;
285
- }
286
- response.data.data.transactions.edges
287
- .map((e) => {
288
- const contractTag = e.node.tags.find((t) => t.name === 'Contract');
289
- // we want to preserve the cursor here, so add even if a duplicate and the set will handle removing the contract if its a duplicate
290
- return {
291
- id: contractTag?.value,
292
- tags: [],
293
- data: 0,
294
- };
295
- })
296
- .forEach((c) => {
297
- if (c.tx?.id) {
298
- protocolTxs.add(c.tx);
299
- }
300
- });
301
- cursor =
302
- response.data.data.transactions.edges[exports.MAX_REQUEST_SIZE - 1]?.cursor ??
303
- undefined;
304
- hasNextPage =
305
- response.data.data.transactions.pageInfo?.hasNextPage ?? false;
306
- } while (hasNextPage);
307
- return [...protocolTxs];
308
- }
309
- exports.getContractsTransferredToOrControlledByWallet = getContractsTransferredToOrControlledByWallet;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isContractTxIdConfiguration = exports.isContractConfiguration = exports.getContractManifest = exports.SmartWeaveSortKey = exports.isSortKey = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const arweave_js_1 = require("./arweave.js");
6
- function isSortKey(sortKey) {
7
- return SmartWeaveSortKey.validate(sortKey);
8
- }
9
- exports.isSortKey = isSortKey;
10
- class SmartWeaveSortKey {
11
- _sortKey;
12
- constructor(sortKey) {
13
- if (!SmartWeaveSortKey.validate(sortKey)) {
14
- throw new Error(`Invalid sort key: ${sortKey}`);
15
- }
16
- this._sortKey = sortKey;
17
- }
18
- static validate(sortKey) {
19
- return constants_js_1.SORT_KEY_REGEX.test(sortKey);
20
- }
21
- toString() {
22
- return this._sortKey;
23
- }
24
- parts() {
25
- return this._sortKey.split(',');
26
- }
27
- blockHeight() {
28
- return parseInt(this.parts()[0]);
29
- }
30
- timestamp() {
31
- return parseInt(this.parts()[1]);
32
- }
33
- hash() {
34
- return this.parts()[2];
35
- }
36
- }
37
- exports.SmartWeaveSortKey = SmartWeaveSortKey;
38
- async function getContractManifest({ arweave, contractTxId, }) {
39
- const { tags: encodedTags } = await arweave.transactions
40
- .get(contractTxId)
41
- .catch(() => ({ tags: [] }));
42
- const decodedTags = (0, arweave_js_1.tagsToObject)(encodedTags);
43
- const contractManifestString = decodedTags['Contract-Manifest'] ?? '{}';
44
- // TODO throw if manifest is missing
45
- const contractManifest = JSON.parse(contractManifestString);
46
- return contractManifest;
47
- }
48
- exports.getContractManifest = getContractManifest;
49
- function isContractConfiguration(config) {
50
- return 'contract' in config;
51
- }
52
- exports.isContractConfiguration = isContractConfiguration;
53
- function isContractTxIdConfiguration(config) {
54
- return ('contractTxId' in config &&
55
- typeof config.contractTxId === 'string' &&
56
- (0, arweave_js_1.validateArweaveId)(config.contractTxId) === true);
57
- }
58
- exports.isContractTxIdConfiguration = isContractTxIdConfiguration;
@@ -1 +0,0 @@
1
- export {};