@yodlpay/tokenlists 1.1.5 → 1.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yodlpay/tokenlists",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Tokenlist typings, schema and lists.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,6 +10,21 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.cjs"
13
+ },
14
+ "./tokens": {
15
+ "types": "./dist/tokens.d.ts",
16
+ "import": "./dist/tokens.js",
17
+ "require": "./dist/tokens.cjs"
18
+ },
19
+ "./chains": {
20
+ "types": "./dist/chains.d.ts",
21
+ "import": "./dist/chains.js",
22
+ "require": "./dist/chains.cjs"
23
+ },
24
+ "./abis": {
25
+ "types": "./dist/abis-ts.d.ts",
26
+ "import": "./dist/abis-ts.js",
27
+ "require": "./dist/abis-ts.cjs"
13
28
  }
14
29
  },
15
30
  "files": [
@@ -23,7 +38,6 @@
23
38
  "scripts": {
24
39
  "start": "tsdx watch",
25
40
  "build": "tsdx build",
26
- "postbuild": "mkdir -p dist/tokens && cp src/tokens/tokenlist-*.json src/tokens/tokenlist.schema.json dist/tokens/",
27
41
  "lint": "tsdx lint src",
28
42
  "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
29
43
  "test": "jest",
@@ -44,6 +58,9 @@
44
58
  "singleQuote": true,
45
59
  "trailingComma": "es5"
46
60
  },
61
+ "peerDependencies": {
62
+ "viem": ">=2.0.0"
63
+ },
47
64
  "devDependencies": {
48
65
  "@hono/node-server": "^1.19.9",
49
66
  "@semantic-release/changelog": "^6.0.3",
@@ -1,184 +0,0 @@
1
- var index = require('./index-BqYpjiy9.cjs');
2
-
3
- class OffchainLookupError extends index.BaseError {
4
- constructor({ callbackSelector, cause, data, extraData, sender, urls }){
5
- super(cause.shortMessage || 'An error occurred while fetching for an offchain result.', {
6
- cause,
7
- metaMessages: [
8
- ...cause.metaMessages || [],
9
- cause.metaMessages?.length ? '' : [],
10
- 'Offchain Gateway Call:',
11
- urls && [
12
- ' Gateway URL(s):',
13
- ...urls.map((url)=>` ${index.getUrl(url)}`)
14
- ],
15
- ` Sender: ${sender}`,
16
- ` Data: ${data}`,
17
- ` Callback selector: ${callbackSelector}`,
18
- ` Extra data: ${extraData}`
19
- ].flat(),
20
- name: 'OffchainLookupError'
21
- });
22
- }
23
- }
24
- class OffchainLookupResponseMalformedError extends index.BaseError {
25
- constructor({ result, url }){
26
- super('Offchain gateway response is malformed. Response data must be a hex value.', {
27
- metaMessages: [
28
- `Gateway URL: ${index.getUrl(url)}`,
29
- `Response: ${index.stringify(result)}`
30
- ],
31
- name: 'OffchainLookupResponseMalformedError'
32
- });
33
- }
34
- }
35
- class OffchainLookupSenderMismatchError extends index.BaseError {
36
- constructor({ sender, to }){
37
- super('Reverted sender address does not match target contract address (`to`).', {
38
- metaMessages: [
39
- `Contract address: ${to}`,
40
- `OffchainLookup sender address: ${sender}`
41
- ],
42
- name: 'OffchainLookupSenderMismatchError'
43
- });
44
- }
45
- }
46
-
47
- const offchainLookupSignature = '0x556f1830';
48
- const offchainLookupAbiItem = {
49
- name: 'OffchainLookup',
50
- type: 'error',
51
- inputs: [
52
- {
53
- name: 'sender',
54
- type: 'address'
55
- },
56
- {
57
- name: 'urls',
58
- type: 'string[]'
59
- },
60
- {
61
- name: 'callData',
62
- type: 'bytes'
63
- },
64
- {
65
- name: 'callbackFunction',
66
- type: 'bytes4'
67
- },
68
- {
69
- name: 'extraData',
70
- type: 'bytes'
71
- }
72
- ]
73
- };
74
- async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
75
- const { args } = index.decodeErrorResult({
76
- data,
77
- abi: [
78
- offchainLookupAbiItem
79
- ]
80
- });
81
- const [sender, urls, callData, callbackSelector, extraData] = args;
82
- const { ccipRead } = client;
83
- const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function' ? ccipRead.request : ccipRequest;
84
- try {
85
- if (!index.isAddressEqual(to, sender)) throw new OffchainLookupSenderMismatchError({
86
- sender,
87
- to
88
- });
89
- const result = urls.includes(index.localBatchGatewayUrl) ? await index.localBatchGatewayRequest({
90
- data: callData,
91
- ccipRequest: ccipRequest_
92
- }) : await ccipRequest_({
93
- data: callData,
94
- sender,
95
- urls
96
- });
97
- const { data: data_ } = await index.call(client, {
98
- blockNumber,
99
- blockTag,
100
- data: index.concat([
101
- callbackSelector,
102
- index.encodeAbiParameters([
103
- {
104
- type: 'bytes'
105
- },
106
- {
107
- type: 'bytes'
108
- }
109
- ], [
110
- result,
111
- extraData
112
- ])
113
- ]),
114
- to
115
- });
116
- return data_;
117
- } catch (err) {
118
- throw new OffchainLookupError({
119
- callbackSelector,
120
- cause: err,
121
- data,
122
- extraData,
123
- sender,
124
- urls
125
- });
126
- }
127
- }
128
- async function ccipRequest({ data, sender, urls }) {
129
- let error = new Error('An unknown error occurred.');
130
- for(let i = 0; i < urls.length; i++){
131
- const url = urls[i];
132
- const method = url.includes('{data}') ? 'GET' : 'POST';
133
- const body = method === 'POST' ? {
134
- data,
135
- sender
136
- } : undefined;
137
- const headers = method === 'POST' ? {
138
- 'Content-Type': 'application/json'
139
- } : {};
140
- try {
141
- const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {
142
- body: JSON.stringify(body),
143
- headers,
144
- method
145
- });
146
- let result;
147
- if (response.headers.get('Content-Type')?.startsWith('application/json')) {
148
- result = (await response.json()).data;
149
- } else {
150
- result = await response.text();
151
- }
152
- if (!response.ok) {
153
- error = new index.HttpRequestError({
154
- body,
155
- details: result?.error ? index.stringify(result.error) : response.statusText,
156
- headers: response.headers,
157
- status: response.status,
158
- url
159
- });
160
- continue;
161
- }
162
- if (!index.isHex(result)) {
163
- error = new OffchainLookupResponseMalformedError({
164
- result,
165
- url
166
- });
167
- continue;
168
- }
169
- return result;
170
- } catch (err) {
171
- error = new index.HttpRequestError({
172
- body,
173
- details: err.message,
174
- url
175
- });
176
- }
177
- }
178
- throw error;
179
- }
180
-
181
- exports.ccipRequest = ccipRequest;
182
- exports.offchainLookup = offchainLookup;
183
- exports.offchainLookupAbiItem = offchainLookupAbiItem;
184
- exports.offchainLookupSignature = offchainLookupSignature;
@@ -1,181 +0,0 @@
1
- import { B as BaseError, g as getUrl, s as stringify, d as decodeErrorResult, i as isAddressEqual, l as localBatchGatewayUrl, a as localBatchGatewayRequest, c as call, b as concat, e as encodeAbiParameters, H as HttpRequestError, f as isHex } from './index-CIWcrB8e.js';
2
-
3
- class OffchainLookupError extends BaseError {
4
- constructor({ callbackSelector, cause, data, extraData, sender, urls }){
5
- super(cause.shortMessage || 'An error occurred while fetching for an offchain result.', {
6
- cause,
7
- metaMessages: [
8
- ...cause.metaMessages || [],
9
- cause.metaMessages?.length ? '' : [],
10
- 'Offchain Gateway Call:',
11
- urls && [
12
- ' Gateway URL(s):',
13
- ...urls.map((url)=>` ${getUrl(url)}`)
14
- ],
15
- ` Sender: ${sender}`,
16
- ` Data: ${data}`,
17
- ` Callback selector: ${callbackSelector}`,
18
- ` Extra data: ${extraData}`
19
- ].flat(),
20
- name: 'OffchainLookupError'
21
- });
22
- }
23
- }
24
- class OffchainLookupResponseMalformedError extends BaseError {
25
- constructor({ result, url }){
26
- super('Offchain gateway response is malformed. Response data must be a hex value.', {
27
- metaMessages: [
28
- `Gateway URL: ${getUrl(url)}`,
29
- `Response: ${stringify(result)}`
30
- ],
31
- name: 'OffchainLookupResponseMalformedError'
32
- });
33
- }
34
- }
35
- class OffchainLookupSenderMismatchError extends BaseError {
36
- constructor({ sender, to }){
37
- super('Reverted sender address does not match target contract address (`to`).', {
38
- metaMessages: [
39
- `Contract address: ${to}`,
40
- `OffchainLookup sender address: ${sender}`
41
- ],
42
- name: 'OffchainLookupSenderMismatchError'
43
- });
44
- }
45
- }
46
-
47
- const offchainLookupSignature = '0x556f1830';
48
- const offchainLookupAbiItem = {
49
- name: 'OffchainLookup',
50
- type: 'error',
51
- inputs: [
52
- {
53
- name: 'sender',
54
- type: 'address'
55
- },
56
- {
57
- name: 'urls',
58
- type: 'string[]'
59
- },
60
- {
61
- name: 'callData',
62
- type: 'bytes'
63
- },
64
- {
65
- name: 'callbackFunction',
66
- type: 'bytes4'
67
- },
68
- {
69
- name: 'extraData',
70
- type: 'bytes'
71
- }
72
- ]
73
- };
74
- async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
75
- const { args } = decodeErrorResult({
76
- data,
77
- abi: [
78
- offchainLookupAbiItem
79
- ]
80
- });
81
- const [sender, urls, callData, callbackSelector, extraData] = args;
82
- const { ccipRead } = client;
83
- const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function' ? ccipRead.request : ccipRequest;
84
- try {
85
- if (!isAddressEqual(to, sender)) throw new OffchainLookupSenderMismatchError({
86
- sender,
87
- to
88
- });
89
- const result = urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({
90
- data: callData,
91
- ccipRequest: ccipRequest_
92
- }) : await ccipRequest_({
93
- data: callData,
94
- sender,
95
- urls
96
- });
97
- const { data: data_ } = await call(client, {
98
- blockNumber,
99
- blockTag,
100
- data: concat([
101
- callbackSelector,
102
- encodeAbiParameters([
103
- {
104
- type: 'bytes'
105
- },
106
- {
107
- type: 'bytes'
108
- }
109
- ], [
110
- result,
111
- extraData
112
- ])
113
- ]),
114
- to
115
- });
116
- return data_;
117
- } catch (err) {
118
- throw new OffchainLookupError({
119
- callbackSelector,
120
- cause: err,
121
- data,
122
- extraData,
123
- sender,
124
- urls
125
- });
126
- }
127
- }
128
- async function ccipRequest({ data, sender, urls }) {
129
- let error = new Error('An unknown error occurred.');
130
- for(let i = 0; i < urls.length; i++){
131
- const url = urls[i];
132
- const method = url.includes('{data}') ? 'GET' : 'POST';
133
- const body = method === 'POST' ? {
134
- data,
135
- sender
136
- } : undefined;
137
- const headers = method === 'POST' ? {
138
- 'Content-Type': 'application/json'
139
- } : {};
140
- try {
141
- const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {
142
- body: JSON.stringify(body),
143
- headers,
144
- method
145
- });
146
- let result;
147
- if (response.headers.get('Content-Type')?.startsWith('application/json')) {
148
- result = (await response.json()).data;
149
- } else {
150
- result = await response.text();
151
- }
152
- if (!response.ok) {
153
- error = new HttpRequestError({
154
- body,
155
- details: result?.error ? stringify(result.error) : response.statusText,
156
- headers: response.headers,
157
- status: response.status,
158
- url
159
- });
160
- continue;
161
- }
162
- if (!isHex(result)) {
163
- error = new OffchainLookupResponseMalformedError({
164
- result,
165
- url
166
- });
167
- continue;
168
- }
169
- return result;
170
- } catch (err) {
171
- error = new HttpRequestError({
172
- body,
173
- details: err.message,
174
- url
175
- });
176
- }
177
- }
178
- throw error;
179
- }
180
-
181
- export { ccipRequest, offchainLookup, offchainLookupAbiItem, offchainLookupSignature };