hpw-convert-eip681 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Osumi Akari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class ParsedLink {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ toEip681(): string;
9
+ readonly amount: string | undefined;
10
+ readonly amountHex: string | undefined;
11
+ readonly chainId: number;
12
+ readonly currencyContract: string;
13
+ readonly currencySymbol: string;
14
+ readonly to: string;
15
+ readonly toName: string | undefined;
16
+ }
17
+
18
+ export function isSupported(url: string): boolean;
19
+
20
+ export function isValidChecksum(address: string): boolean;
21
+
22
+ export function parseHashportLink(url: string): ParsedLink;
23
+
24
+ export function start(): void;
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./hpw_convert_eip681.d.ts" */
2
+ import * as wasm from "./hpw_convert_eip681_bg.wasm";
3
+ import { __wbg_set_wasm } from "./hpw_convert_eip681_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ ParsedLink, isSupported, isValidChecksum, parseHashportLink, start
9
+ } from "./hpw_convert_eip681_bg.js";
@@ -0,0 +1,309 @@
1
+ export class ParsedLink {
2
+ static __wrap(ptr) {
3
+ const obj = Object.create(ParsedLink.prototype);
4
+ obj.__wbg_ptr = ptr;
5
+ ParsedLinkFinalization.register(obj, obj.__wbg_ptr, obj);
6
+ return obj;
7
+ }
8
+ __destroy_into_raw() {
9
+ const ptr = this.__wbg_ptr;
10
+ this.__wbg_ptr = 0;
11
+ ParsedLinkFinalization.unregister(this);
12
+ return ptr;
13
+ }
14
+ free() {
15
+ const ptr = this.__destroy_into_raw();
16
+ wasm.__wbg_parsedlink_free(ptr, 0);
17
+ }
18
+ /**
19
+ * @returns {string | undefined}
20
+ */
21
+ get amount() {
22
+ const ret = wasm.parsedlink_amount(this.__wbg_ptr);
23
+ let v1;
24
+ if (ret[0] !== 0) {
25
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
26
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
27
+ }
28
+ return v1;
29
+ }
30
+ /**
31
+ * @returns {string | undefined}
32
+ */
33
+ get amountHex() {
34
+ const ret = wasm.parsedlink_amountHex(this.__wbg_ptr);
35
+ let v1;
36
+ if (ret[0] !== 0) {
37
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
38
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
39
+ }
40
+ return v1;
41
+ }
42
+ /**
43
+ * @returns {number}
44
+ */
45
+ get chainId() {
46
+ const ret = wasm.parsedlink_chainId(this.__wbg_ptr);
47
+ return ret >>> 0;
48
+ }
49
+ /**
50
+ * @returns {string}
51
+ */
52
+ get currencyContract() {
53
+ let deferred1_0;
54
+ let deferred1_1;
55
+ try {
56
+ const ret = wasm.parsedlink_currencyContract(this.__wbg_ptr);
57
+ deferred1_0 = ret[0];
58
+ deferred1_1 = ret[1];
59
+ return getStringFromWasm0(ret[0], ret[1]);
60
+ } finally {
61
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
62
+ }
63
+ }
64
+ /**
65
+ * @returns {string}
66
+ */
67
+ get currencySymbol() {
68
+ let deferred1_0;
69
+ let deferred1_1;
70
+ try {
71
+ const ret = wasm.parsedlink_currencySymbol(this.__wbg_ptr);
72
+ deferred1_0 = ret[0];
73
+ deferred1_1 = ret[1];
74
+ return getStringFromWasm0(ret[0], ret[1]);
75
+ } finally {
76
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
77
+ }
78
+ }
79
+ /**
80
+ * @returns {string}
81
+ */
82
+ get to() {
83
+ let deferred1_0;
84
+ let deferred1_1;
85
+ try {
86
+ const ret = wasm.parsedlink_to(this.__wbg_ptr);
87
+ deferred1_0 = ret[0];
88
+ deferred1_1 = ret[1];
89
+ return getStringFromWasm0(ret[0], ret[1]);
90
+ } finally {
91
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
92
+ }
93
+ }
94
+ /**
95
+ * @returns {string}
96
+ */
97
+ toEip681() {
98
+ let deferred1_0;
99
+ let deferred1_1;
100
+ try {
101
+ const ret = wasm.parsedlink_toEip681(this.__wbg_ptr);
102
+ deferred1_0 = ret[0];
103
+ deferred1_1 = ret[1];
104
+ return getStringFromWasm0(ret[0], ret[1]);
105
+ } finally {
106
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
107
+ }
108
+ }
109
+ /**
110
+ * @returns {string | undefined}
111
+ */
112
+ get toName() {
113
+ const ret = wasm.parsedlink_toName(this.__wbg_ptr);
114
+ let v1;
115
+ if (ret[0] !== 0) {
116
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
117
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
118
+ }
119
+ return v1;
120
+ }
121
+ }
122
+ if (Symbol.dispose) ParsedLink.prototype[Symbol.dispose] = ParsedLink.prototype.free;
123
+
124
+ /**
125
+ * @param {string} url
126
+ * @returns {boolean}
127
+ */
128
+ export function isSupported(url) {
129
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
130
+ const len0 = WASM_VECTOR_LEN;
131
+ const ret = wasm.isSupported(ptr0, len0);
132
+ return ret !== 0;
133
+ }
134
+
135
+ /**
136
+ * @param {string} address
137
+ * @returns {boolean}
138
+ */
139
+ export function isValidChecksum(address) {
140
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
141
+ const len0 = WASM_VECTOR_LEN;
142
+ const ret = wasm.isValidChecksum(ptr0, len0);
143
+ return ret !== 0;
144
+ }
145
+
146
+ /**
147
+ * @param {string} url
148
+ * @returns {ParsedLink}
149
+ */
150
+ export function parseHashportLink(url) {
151
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
152
+ const len0 = WASM_VECTOR_LEN;
153
+ const ret = wasm.parseHashportLink(ptr0, len0);
154
+ if (ret[2]) {
155
+ throw takeFromExternrefTable0(ret[1]);
156
+ }
157
+ return ParsedLink.__wrap(ret[0]);
158
+ }
159
+
160
+ export function start() {
161
+ wasm.start();
162
+ }
163
+ export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
164
+ throw new Error(getStringFromWasm0(arg0, arg1));
165
+ }
166
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
167
+ let deferred0_0;
168
+ let deferred0_1;
169
+ try {
170
+ deferred0_0 = arg0;
171
+ deferred0_1 = arg1;
172
+ console.error(getStringFromWasm0(arg0, arg1));
173
+ } finally {
174
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
175
+ }
176
+ }
177
+ export function __wbg_new_227d7c05414eb861() {
178
+ const ret = new Error();
179
+ return ret;
180
+ }
181
+ export function __wbg_new_da52cf8fe3429cb2() {
182
+ const ret = new Object();
183
+ return ret;
184
+ }
185
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
186
+ arg0[arg1] = arg2;
187
+ }
188
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
189
+ const ret = arg1.stack;
190
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
191
+ const len1 = WASM_VECTOR_LEN;
192
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
193
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
194
+ }
195
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
196
+ // Cast intrinsic for `Ref(String) -> Externref`.
197
+ const ret = getStringFromWasm0(arg0, arg1);
198
+ return ret;
199
+ }
200
+ export function __wbindgen_init_externref_table() {
201
+ const table = wasm.__wbindgen_externrefs;
202
+ const offset = table.grow(4);
203
+ table.set(0, undefined);
204
+ table.set(offset + 0, undefined);
205
+ table.set(offset + 1, null);
206
+ table.set(offset + 2, true);
207
+ table.set(offset + 3, false);
208
+ }
209
+ const ParsedLinkFinalization = (typeof FinalizationRegistry === 'undefined')
210
+ ? { register: () => {}, unregister: () => {} }
211
+ : new FinalizationRegistry(ptr => wasm.__wbg_parsedlink_free(ptr, 1));
212
+
213
+ let cachedDataViewMemory0 = null;
214
+ function getDataViewMemory0() {
215
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
216
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
217
+ }
218
+ return cachedDataViewMemory0;
219
+ }
220
+
221
+ function getStringFromWasm0(ptr, len) {
222
+ return decodeText(ptr >>> 0, len);
223
+ }
224
+
225
+ let cachedUint8ArrayMemory0 = null;
226
+ function getUint8ArrayMemory0() {
227
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
228
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
229
+ }
230
+ return cachedUint8ArrayMemory0;
231
+ }
232
+
233
+ function passStringToWasm0(arg, malloc, realloc) {
234
+ if (realloc === undefined) {
235
+ const buf = cachedTextEncoder.encode(arg);
236
+ const ptr = malloc(buf.length, 1) >>> 0;
237
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
238
+ WASM_VECTOR_LEN = buf.length;
239
+ return ptr;
240
+ }
241
+
242
+ let len = arg.length;
243
+ let ptr = malloc(len, 1) >>> 0;
244
+
245
+ const mem = getUint8ArrayMemory0();
246
+
247
+ let offset = 0;
248
+
249
+ for (; offset < len; offset++) {
250
+ const code = arg.charCodeAt(offset);
251
+ if (code > 0x7F) break;
252
+ mem[ptr + offset] = code;
253
+ }
254
+ if (offset !== len) {
255
+ if (offset !== 0) {
256
+ arg = arg.slice(offset);
257
+ }
258
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
259
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
260
+ const ret = cachedTextEncoder.encodeInto(arg, view);
261
+
262
+ offset += ret.written;
263
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
264
+ }
265
+
266
+ WASM_VECTOR_LEN = offset;
267
+ return ptr;
268
+ }
269
+
270
+ function takeFromExternrefTable0(idx) {
271
+ const value = wasm.__wbindgen_externrefs.get(idx);
272
+ wasm.__externref_table_dealloc(idx);
273
+ return value;
274
+ }
275
+
276
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
277
+ cachedTextDecoder.decode();
278
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
279
+ let numBytesDecoded = 0;
280
+ function decodeText(ptr, len) {
281
+ numBytesDecoded += len;
282
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
283
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
284
+ cachedTextDecoder.decode();
285
+ numBytesDecoded = len;
286
+ }
287
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
288
+ }
289
+
290
+ const cachedTextEncoder = new TextEncoder();
291
+
292
+ if (!('encodeInto' in cachedTextEncoder)) {
293
+ cachedTextEncoder.encodeInto = function (arg, view) {
294
+ const buf = cachedTextEncoder.encode(arg);
295
+ view.set(buf);
296
+ return {
297
+ read: arg.length,
298
+ written: buf.length
299
+ };
300
+ };
301
+ }
302
+
303
+ let WASM_VECTOR_LEN = 0;
304
+
305
+
306
+ let wasm;
307
+ export function __wbg_set_wasm(val) {
308
+ wasm = val;
309
+ }
Binary file
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "hpw-convert-eip681",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Osumi Akari"
6
+ ],
7
+ "version": "0.1.0",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/oageo/hpw-convert-eip681.git"
12
+ },
13
+ "files": [
14
+ "hpw_convert_eip681_bg.wasm",
15
+ "hpw_convert_eip681.js",
16
+ "hpw_convert_eip681_bg.js",
17
+ "hpw_convert_eip681.d.ts",
18
+ "LICENSE"
19
+ ],
20
+ "main": "hpw_convert_eip681.js",
21
+ "types": "hpw_convert_eip681.d.ts",
22
+ "sideEffects": [
23
+ "./hpw_convert_eip681.js",
24
+ "./snippets/*"
25
+ ],
26
+ "description": "Unofficial, unaffiliated converter: HashPort Wallet JPYC payment links -> EIP-681 URIs. Not endorsed by or affiliated with HashPort."
27
+ }