@solana/addresses 2.0.0-experimental.0108bc7
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 +20 -0
- package/README.md +83 -0
- package/dist/index.browser.cjs +228 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.js +222 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.development.js +517 -0
- package/dist/index.development.js.map +1 -0
- package/dist/index.native.js +222 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.node.cjs +228 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.js +222 -0
- package/dist/index.node.js.map +1 -0
- package/dist/index.production.min.js +15 -0
- package/dist/types/base58.d.ts +10 -0
- package/dist/types/base58.d.ts.map +1 -0
- package/dist/types/curve.d.ts +2 -0
- package/dist/types/curve.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/program-derived-address.d.ts +12 -0
- package/dist/types/program-derived-address.d.ts.map +1 -0
- package/dist/types/public-key.d.ts +3 -0
- package/dist/types/public-key.d.ts.map +1 -0
- package/dist/types/vendor/noble/ed25519.d.ts +2 -0
- package/dist/types/vendor/noble/ed25519.d.ts.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { base58, string } from '@metaplex-foundation/umi-serializers';
|
|
2
|
+
import { assertKeyExporterIsAvailable, assertDigestCapabilityIsAvailable } from '@solana/assertions';
|
|
3
|
+
|
|
4
|
+
// ../build-scripts/env-shim.ts
|
|
5
|
+
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
|
|
6
|
+
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
|
|
7
|
+
try {
|
|
8
|
+
if (
|
|
9
|
+
// Lowest address (32 bytes of zeroes)
|
|
10
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
11
|
+
putativeBase58EncodedAddress.length > 44
|
|
12
|
+
) {
|
|
13
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
14
|
+
}
|
|
15
|
+
const bytes = base58.serialize(putativeBase58EncodedAddress);
|
|
16
|
+
const numBytes = bytes.byteLength;
|
|
17
|
+
if (numBytes !== 32) {
|
|
18
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
19
|
+
}
|
|
20
|
+
} catch (e) {
|
|
21
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
22
|
+
cause: e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function getBase58EncodedAddressCodec(config) {
|
|
27
|
+
return string({
|
|
28
|
+
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""),
|
|
29
|
+
encoding: base58,
|
|
30
|
+
size: 32
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getBase58EncodedAddressComparator() {
|
|
34
|
+
return new Intl.Collator("en", {
|
|
35
|
+
caseFirst: "lower",
|
|
36
|
+
ignorePunctuation: false,
|
|
37
|
+
localeMatcher: "best fit",
|
|
38
|
+
numeric: false,
|
|
39
|
+
sensitivity: "variant",
|
|
40
|
+
usage: "sort"
|
|
41
|
+
}).compare;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/vendor/noble/ed25519.ts
|
|
45
|
+
var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
|
|
46
|
+
var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
|
|
47
|
+
var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
|
|
48
|
+
function mod(a) {
|
|
49
|
+
const r = a % P;
|
|
50
|
+
return r >= 0n ? r : P + r;
|
|
51
|
+
}
|
|
52
|
+
function pow2(x, power) {
|
|
53
|
+
let r = x;
|
|
54
|
+
while (power-- > 0n) {
|
|
55
|
+
r *= r;
|
|
56
|
+
r %= P;
|
|
57
|
+
}
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
function pow_2_252_3(x) {
|
|
61
|
+
const x2 = x * x % P;
|
|
62
|
+
const b2 = x2 * x % P;
|
|
63
|
+
const b4 = pow2(b2, 2n) * b2 % P;
|
|
64
|
+
const b5 = pow2(b4, 1n) * x % P;
|
|
65
|
+
const b10 = pow2(b5, 5n) * b5 % P;
|
|
66
|
+
const b20 = pow2(b10, 10n) * b10 % P;
|
|
67
|
+
const b40 = pow2(b20, 20n) * b20 % P;
|
|
68
|
+
const b80 = pow2(b40, 40n) * b40 % P;
|
|
69
|
+
const b160 = pow2(b80, 80n) * b80 % P;
|
|
70
|
+
const b240 = pow2(b160, 80n) * b80 % P;
|
|
71
|
+
const b250 = pow2(b240, 10n) * b10 % P;
|
|
72
|
+
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
73
|
+
return pow_p_5_8;
|
|
74
|
+
}
|
|
75
|
+
function uvRatio(u, v) {
|
|
76
|
+
const v3 = mod(v * v * v);
|
|
77
|
+
const v7 = mod(v3 * v3 * v);
|
|
78
|
+
const pow = pow_2_252_3(u * v7);
|
|
79
|
+
let x = mod(u * v3 * pow);
|
|
80
|
+
const vx2 = mod(v * x * x);
|
|
81
|
+
const root1 = x;
|
|
82
|
+
const root2 = mod(x * RM1);
|
|
83
|
+
const useRoot1 = vx2 === u;
|
|
84
|
+
const useRoot2 = vx2 === mod(-u);
|
|
85
|
+
const noRoot = vx2 === mod(-u * RM1);
|
|
86
|
+
if (useRoot1)
|
|
87
|
+
x = root1;
|
|
88
|
+
if (useRoot2 || noRoot)
|
|
89
|
+
x = root2;
|
|
90
|
+
if ((mod(x) & 1n) === 1n)
|
|
91
|
+
x = mod(-x);
|
|
92
|
+
if (!useRoot1 && !useRoot2) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return x;
|
|
96
|
+
}
|
|
97
|
+
function pointIsOnCurve(y, lastByte) {
|
|
98
|
+
const y2 = mod(y * y);
|
|
99
|
+
const u = mod(y2 - 1n);
|
|
100
|
+
const v = mod(D * y2 + 1n);
|
|
101
|
+
const x = uvRatio(u, v);
|
|
102
|
+
if (x === null) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
106
|
+
if (x === 0n && isLastByteOdd) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/curve.ts
|
|
113
|
+
function byteToHex(byte) {
|
|
114
|
+
const hexString = byte.toString(16);
|
|
115
|
+
if (hexString.length === 1) {
|
|
116
|
+
return `0${hexString}`;
|
|
117
|
+
} else {
|
|
118
|
+
return hexString;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function decompressPointBytes(bytes) {
|
|
122
|
+
const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
|
|
123
|
+
const integerLiteralString = `0x${hexString}`;
|
|
124
|
+
return BigInt(integerLiteralString);
|
|
125
|
+
}
|
|
126
|
+
async function compressedPointBytesAreOnCurve(bytes) {
|
|
127
|
+
if (bytes.byteLength !== 32) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const y = decompressPointBytes(bytes);
|
|
131
|
+
return pointIsOnCurve(y, bytes[31]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/program-derived-address.ts
|
|
135
|
+
var MAX_SEED_LENGTH = 32;
|
|
136
|
+
var MAX_SEEDS = 16;
|
|
137
|
+
var PDA_MARKER_BYTES = [
|
|
138
|
+
// The string 'ProgramDerivedAddress'
|
|
139
|
+
80,
|
|
140
|
+
114,
|
|
141
|
+
111,
|
|
142
|
+
103,
|
|
143
|
+
114,
|
|
144
|
+
97,
|
|
145
|
+
109,
|
|
146
|
+
68,
|
|
147
|
+
101,
|
|
148
|
+
114,
|
|
149
|
+
105,
|
|
150
|
+
118,
|
|
151
|
+
101,
|
|
152
|
+
100,
|
|
153
|
+
65,
|
|
154
|
+
100,
|
|
155
|
+
100,
|
|
156
|
+
114,
|
|
157
|
+
101,
|
|
158
|
+
115,
|
|
159
|
+
115
|
|
160
|
+
];
|
|
161
|
+
var PointOnCurveError = class extends Error {
|
|
162
|
+
};
|
|
163
|
+
async function createProgramDerivedAddress({ programAddress, seeds }) {
|
|
164
|
+
await assertDigestCapabilityIsAvailable();
|
|
165
|
+
if (seeds.length > MAX_SEEDS) {
|
|
166
|
+
throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
|
|
167
|
+
}
|
|
168
|
+
let textEncoder;
|
|
169
|
+
const seedBytes = seeds.reduce((acc, seed, ii) => {
|
|
170
|
+
const bytes = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
|
|
171
|
+
if (bytes.byteLength > MAX_SEED_LENGTH) {
|
|
172
|
+
throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
|
|
173
|
+
}
|
|
174
|
+
acc.push(...bytes);
|
|
175
|
+
return acc;
|
|
176
|
+
}, []);
|
|
177
|
+
const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
|
|
178
|
+
const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
|
|
179
|
+
const addressBytesBuffer = await crypto.subtle.digest(
|
|
180
|
+
"SHA-256",
|
|
181
|
+
new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
|
|
182
|
+
);
|
|
183
|
+
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
184
|
+
if (await compressedPointBytesAreOnCurve(addressBytes)) {
|
|
185
|
+
throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
|
|
186
|
+
}
|
|
187
|
+
return base58EncodedAddressCodec.deserialize(addressBytes)[0];
|
|
188
|
+
}
|
|
189
|
+
async function getProgramDerivedAddress({ programAddress, seeds }) {
|
|
190
|
+
let bumpSeed = 255;
|
|
191
|
+
while (bumpSeed > 0) {
|
|
192
|
+
try {
|
|
193
|
+
return {
|
|
194
|
+
bumpSeed,
|
|
195
|
+
pda: await createProgramDerivedAddress({
|
|
196
|
+
programAddress,
|
|
197
|
+
seeds: [...seeds, new Uint8Array([bumpSeed])]
|
|
198
|
+
})
|
|
199
|
+
};
|
|
200
|
+
} catch (e) {
|
|
201
|
+
if (e instanceof PointOnCurveError) {
|
|
202
|
+
bumpSeed--;
|
|
203
|
+
} else {
|
|
204
|
+
throw e;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
throw new Error("Unable to find a viable program address bump seed");
|
|
209
|
+
}
|
|
210
|
+
async function getBase58EncodedAddressFromPublicKey(publicKey) {
|
|
211
|
+
await assertKeyExporterIsAvailable();
|
|
212
|
+
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
213
|
+
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
214
|
+
}
|
|
215
|
+
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
216
|
+
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
217
|
+
return base58EncodedAddress;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export { assertIsBase58EncodedAddress, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getBase58EncodedAddressFromPublicKey, getProgramDerivedAddress };
|
|
221
|
+
//# sourceMappingURL=out.js.map
|
|
222
|
+
//# sourceMappingURL=index.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/base58.ts","../src/program-derived-address.ts","../src/vendor/noble/ed25519.ts","../src/curve.ts","../src/public-key.ts"],"names":[],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,QAAoB,cAAc;AAMpC,SAAS,6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,IAAI,MAAM,iDAAiD;AAAA,EACrE;AACA,QAAM,iBAAiB,MAAM,OAAO,OAAO,UAAU,OAAO,SAAS;AACrE,QAAM,CAAC,oBAAoB,IAAI,6BAA6B,EAAE,YAAY,IAAI,WAAW,cAAc,CAAC;AACxG,SAAO;AACX","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58, Serializer, string } from '@metaplex-foundation/umi-serializers';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressCodec(\n config?: Readonly<{\n description: string;\n }>\n): Serializer<Base58EncodedAddress> {\n return string({\n description: config?.description ?? (__DEV__ ? 'A 32-byte account address' : ''),\n encoding: base58,\n size: 32,\n }) as unknown as Serializer<Base58EncodedAddress>;\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n","import { assertDigestCapabilityIsAvailable } from '@solana/assertions';\n\nimport { Base58EncodedAddress, getBase58EncodedAddressCodec } from './base58';\nimport { compressedPointBytesAreOnCurve } from './curve';\n\ntype PDAInput = Readonly<{\n programAddress: Base58EncodedAddress;\n seeds: Seed[];\n}>;\ntype Seed = string | Uint8Array;\n\nconst MAX_SEED_LENGTH = 32;\nconst MAX_SEEDS = 16;\nconst PDA_MARKER_BYTES = [\n // The string 'ProgramDerivedAddress'\n 80, 114, 111, 103, 114, 97, 109, 68, 101, 114, 105, 118, 101, 100, 65, 100, 100, 114, 101, 115, 115,\n] as const;\n\n// TODO: Coded error.\nclass PointOnCurveError extends Error {}\n\nasync function createProgramDerivedAddress({ programAddress, seeds }: PDAInput): Promise<Base58EncodedAddress> {\n await assertDigestCapabilityIsAvailable();\n if (seeds.length > MAX_SEEDS) {\n // TODO: Coded error.\n throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);\n }\n let textEncoder: TextEncoder;\n const seedBytes = seeds.reduce((acc, seed, ii) => {\n const bytes = typeof seed === 'string' ? (textEncoder ||= new TextEncoder()).encode(seed) : seed;\n if (bytes.byteLength > MAX_SEED_LENGTH) {\n // TODO: Coded error.\n throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);\n }\n acc.push(...bytes);\n return acc;\n }, [] as number[]);\n const base58EncodedAddressCodec = getBase58EncodedAddressCodec();\n const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);\n const addressBytesBuffer = await crypto.subtle.digest(\n 'SHA-256',\n new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])\n );\n const addressBytes = new Uint8Array(addressBytesBuffer);\n if (await compressedPointBytesAreOnCurve(addressBytes)) {\n // TODO: Coded error.\n throw new PointOnCurveError('Invalid seeds; point must fall off the Ed25519 curve');\n }\n return base58EncodedAddressCodec.deserialize(addressBytes)[0];\n}\n\nexport async function getProgramDerivedAddress({ programAddress, seeds }: PDAInput): Promise<\n Readonly<{\n bumpSeed: number;\n pda: Base58EncodedAddress;\n }>\n> {\n let bumpSeed = 255;\n while (bumpSeed > 0) {\n try {\n return {\n bumpSeed,\n pda: await createProgramDerivedAddress({\n programAddress,\n seeds: [...seeds, new Uint8Array([bumpSeed])],\n }),\n };\n } catch (e) {\n if (e instanceof PointOnCurveError) {\n bumpSeed--;\n } else {\n throw e;\n }\n }\n }\n // TODO: Coded error.\n throw new Error('Unable to find a viable program address bump seed');\n}\n","/**!\n * noble-ed25519\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2019 Paul Miller (https://paulmillr.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the “Software”), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\nconst D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;\nconst P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n; // 2n ** 255n - 19n; ed25519 is twisted edwards curve\nconst RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n; // √-1\n\n// mod division\nfunction mod(a: bigint): bigint {\n const r = a % P;\n return r >= 0n ? r : P + r;\n}\nfunction pow2(x: bigint, power: bigint): bigint {\n // pow2(x, 4) == x^(2^4)\n let r = x;\n while (power-- > 0n) {\n r *= r;\n r %= P;\n }\n return r;\n}\nfunction pow_2_252_3(x: bigint): bigint {\n // x^(2^252-3) unrolled util for square root\n const x2 = (x * x) % P; // x^2, bits 1\n const b2 = (x2 * x) % P; // x^3, bits 11\n const b4 = (pow2(b2, 2n) * b2) % P; // x^(2^4-1), bits 1111\n const b5 = (pow2(b4, 1n) * x) % P; // x^(2^5-1), bits 11111\n const b10 = (pow2(b5, 5n) * b5) % P; // x^(2^10)\n const b20 = (pow2(b10, 10n) * b10) % P; // x^(2^20)\n const b40 = (pow2(b20, 20n) * b20) % P; // x^(2^40)\n const b80 = (pow2(b40, 40n) * b40) % P; // x^(2^80)\n const b160 = (pow2(b80, 80n) * b80) % P; // x^(2^160)\n const b240 = (pow2(b160, 80n) * b80) % P; // x^(2^240)\n const b250 = (pow2(b240, 10n) * b10) % P; // x^(2^250)\n const pow_p_5_8 = (pow2(b250, 2n) * x) % P; // < To pow to (p+3)/8, multiply it by x.\n return pow_p_5_8;\n}\nfunction uvRatio(u: bigint, v: bigint): bigint | null {\n // for sqrt comp\n const v3 = mod(v * v * v); // v³\n const v7 = mod(v3 * v3 * v); // v⁷\n const pow = pow_2_252_3(u * v7); // (uv⁷)^(p-5)/8\n let x = mod(u * v3 * pow); // (uv³)(uv⁷)^(p-5)/8\n const vx2 = mod(v * x * x); // vx²\n const root1 = x; // First root candidate\n const root2 = mod(x * RM1); // Second root candidate; RM1 is √-1\n const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root\n const useRoot2 = vx2 === mod(-u); // If vx² = -u, set x <-- x * 2^((p-1)/4)\n const noRoot = vx2 === mod(-u * RM1); // There is no valid root, vx² = -u√-1\n if (useRoot1) x = root1;\n if (useRoot2 || noRoot) x = root2; // We return root2 anyway, for const-time\n if ((mod(x) & 1n) === 1n) x = mod(-x); // edIsNegative\n if (!useRoot1 && !useRoot2) {\n return null;\n }\n return x;\n}\n// https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.3\nexport function pointIsOnCurve(y: bigint, lastByte: number): boolean {\n const y2 = mod(y * y); // y²\n const u = mod(y2 - 1n); // u=y²-1\n const v = mod(D * y2 + 1n);\n const x = uvRatio(u, v); // (uv³)(uv⁷)^(p-5)/8; square root\n if (x === null) {\n return false;\n }\n const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit\n if (x === 0n && isLastByteOdd) {\n return false;\n }\n return true;\n}\n","import { pointIsOnCurve } from './vendor/noble/ed25519';\n\nfunction byteToHex(byte: number): string {\n const hexString = byte.toString(16);\n if (hexString.length === 1) {\n return `0${hexString}`;\n } else {\n return hexString;\n }\n}\n\nfunction decompressPointBytes(bytes: Uint8Array): bigint {\n const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~0x80 : byte)}${acc}`, '');\n const integerLiteralString = `0x${hexString}`;\n return BigInt(integerLiteralString);\n}\n\nexport async function compressedPointBytesAreOnCurve(bytes: Uint8Array): Promise<boolean> {\n if (bytes.byteLength !== 32) {\n return false;\n }\n const y = decompressPointBytes(bytes);\n return pointIsOnCurve(y, bytes[31]);\n}\n","import { assertKeyExporterIsAvailable } from '@solana/assertions';\n\nimport { Base58EncodedAddress, getBase58EncodedAddressCodec } from './base58';\n\nexport async function getBase58EncodedAddressFromPublicKey(publicKey: CryptoKey): Promise<Base58EncodedAddress> {\n await assertKeyExporterIsAvailable();\n if (publicKey.type !== 'public' || publicKey.algorithm.name !== 'Ed25519') {\n // TODO: Coded error.\n throw new Error('The `CryptoKey` must be an `Ed25519` public key');\n }\n const publicKeyBytes = await crypto.subtle.exportKey('raw', publicKey);\n const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));\n return base58EncodedAddress;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
this.globalThis = this.globalThis || {};
|
|
2
|
+
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var X=Object.defineProperty;var M=(e,r,t)=>r in e?X(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var x=(e,r,t)=>(M(e,typeof r!="symbol"?r+"":r,t),t);var v=e=>{let r=e.reduce((i,o)=>i+o.length,0),t=new Uint8Array(r),n=0;return e.forEach(i=>{t.set(i,n),n+=i.length;}),t},_=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},h=(e,r)=>_(e.slice(0,r),r);var b=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);x(this,"name","DeserializingEmptyBufferError");}},y=class extends Error{constructor(t,n,i){super(`Serializer [${t}] expected ${n} bytes, got ${i}.`);x(this,"name","NotEnoughBytesError");}};function I(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:n=>h(e.serialize(n),r),deserialize:(n,i=0)=>{if(n=n.slice(i,i+r),n.length<r)throw new y("fixSerializer",r,n.length);e.fixedSize!==null&&(n=h(n,e.fixedSize));let[o]=e.deserialize(n,0);return [o,i+r]}}}var E=class extends Error{constructor(t,n,i){let o=`Expected a string of base ${n}, got [${t}].`;super(o);x(this,"name","InvalidBaseStringError");this.cause=i;}};var $=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new E(n,r);if(n==="")return new Uint8Array;let i=[...n],o=i.findIndex(d=>d!==e[0]);o=o===-1?i.length:o;let s=Array(o).fill(0);if(o===i.length)return Uint8Array.from(s);let f=i.slice(o),c=0n,l=1n;for(let d=f.length-1;d>=0;d-=1)c+=l*BigInt(e.indexOf(f[d])),l*=t;let u=[];for(;c>0n;)u.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(s.concat(u))},deserialize(n,i=0){if(n.length===0)return ["",0];let o=n.slice(i),s=o.findIndex(u=>u!==0);s=s===-1?o.length:s;let f=e[0].repeat(s);if(s===o.length)return [f,n.length];let c=o.slice(s).reduce((u,d)=>u*256n+BigInt(d),0n),l=[];for(;c>0n;)l.unshift(e[Number(c%t)]),c/=t;return [f+l.join(""),n.length]}}};var w=$("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var T=e=>e.replace(/\u0000/g,"");var C={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let t=new TextDecoder().decode(e.slice(r));return [T(t),e.length]}};var z;(function(e){e.Little="le",e.Big="be";})(z||(z={}));var S=class extends RangeError{constructor(t,n,i,o){super(`Serializer [${t}] expected number to be between ${n} and ${i}, got ${o}.`);x(this,"name","NumberOutOfRangeError");}};function U(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===z.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(n){e.range&&H(e.name,e.range[0],e.range[1],n);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),n,r),new Uint8Array(i)},deserialize(n,i=0){let o=n.slice(i,i+e.size);W("i8",o,e.size);let s=G(o);return [e.get(s,r),i+e.size]}}}var j=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),G=e=>new DataView(j(e)),H=(e,r,t,n)=>{if(n<r||n>t)throw new S(e,r,t,n)},W=(e,r,t)=>{if(r.length===0)throw new b(e);if(r.length<t)throw new y(e,t,r.length)};var D=(e={})=>U({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,Number(t),n),get:(r,t)=>r.getUint32(0,t),options:e});function R(e){return typeof e=="object"?e.description:`${e}`}function N(e={}){let r=e.size??D(),t=e.encoding??C,n=e.description??`string(${t.description}; ${R(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?I(t,r,n):{description:n,fixedSize:null,maxSize:null,serialize:i=>{let o=t.serialize(i),s=r.serialize(o.length);return v([s,o])},deserialize:(i,o=0)=>{if(i.slice(o).length===0)throw new b("string");let[s,f]=r.deserialize(i,o),c=Number(s);o=f;let l=i.slice(o,o+c);if(l.length<c)throw new y("string",c,l.length);let[u,d]=t.deserialize(l);return o+=d,[u,o]}}}function xr(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=w.serialize(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function A(e){return N({description:e?.description??"",encoding:w,size:32})}function br(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function P(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}async function O(){if(P(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!="function")throw new Error("No digest implementation could be found")}async function L(){if(P(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}var Z=37095705934669439343138083508754565189542113879843219016388785533085940283555n,p=57896044618658097711785492504343953926634992332820282019728792003956564819949n,K=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function m(e){let r=e%p;return r>=0n?r:p+r}function g(e,r){let t=e;for(;r-- >0n;)t*=t,t%=p;return t}function q(e){let t=e*e%p*e%p,n=g(t,2n)*t%p,i=g(n,1n)*e%p,o=g(i,5n)*i%p,s=g(o,10n)*o%p,f=g(s,20n)*s%p,c=g(f,40n)*f%p,l=g(c,80n)*c%p,u=g(l,80n)*c%p,d=g(u,10n)*o%p;return g(d,2n)*e%p}function Y(e,r){let t=m(r*r*r),n=m(t*t*r),i=q(e*n),o=m(e*t*i),s=m(r*o*o),f=o,c=m(o*K),l=s===e,u=s===m(-e),d=s===m(-e*K);return l&&(o=f),(u||d)&&(o=c),(m(o)&1n)===1n&&(o=m(-o)),!l&&!u?null:o}function k(e,r){let t=m(e*e),n=m(t-1n),i=m(Z*t+1n),o=Y(n,i);if(o===null)return !1;let s=(r&128)!==0;return !(o===0n&&s)}function J(e){let r=e.toString(16);return r.length===1?`0${r}`:r}function Q(e){let t=`0x${e.reduce((n,i,o)=>`${J(o===31?i&-129:i)}${n}`,"")}`;return BigInt(t)}async function V(e){if(e.byteLength!==32)return !1;let r=Q(e);return k(r,e[31])}var ee=32,F=16,re=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115],B=class extends Error{};async function te({programAddress:e,seeds:r}){if(await O(),r.length>F)throw new Error(`A maximum of ${F} seeds may be supplied when creating an address`);let t,n=r.reduce((c,l,u)=>{let d=typeof l=="string"?(t||(t=new TextEncoder)).encode(l):l;if(d.byteLength>ee)throw new Error(`The seed at index ${u} exceeds the maximum length of 32 bytes`);return c.push(...d),c},[]),i=A(),o=i.serialize(e),s=await crypto.subtle.digest("SHA-256",new Uint8Array([...n,...o,...re])),f=new Uint8Array(s);if(await V(f))throw new B("Invalid seeds; point must fall off the Ed25519 curve");return i.deserialize(f)[0]}async function $r({programAddress:e,seeds:r}){let t=255;for(;t>0;)try{return {bumpSeed:t,pda:await te({programAddress:e,seeds:[...r,new Uint8Array([t])]})}}catch(n){if(n instanceof B)t--;else throw n}throw new Error("Unable to find a viable program address bump seed")}async function Lr(e){if(await L(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let r=await crypto.subtle.exportKey("raw",e),[t]=A().deserialize(new Uint8Array(r));return t}
|
|
6
|
+
|
|
7
|
+
exports.assertIsBase58EncodedAddress = xr;
|
|
8
|
+
exports.getBase58EncodedAddressCodec = A;
|
|
9
|
+
exports.getBase58EncodedAddressComparator = br;
|
|
10
|
+
exports.getBase58EncodedAddressFromPublicKey = Lr;
|
|
11
|
+
exports.getProgramDerivedAddress = $r;
|
|
12
|
+
|
|
13
|
+
return exports;
|
|
14
|
+
|
|
15
|
+
})({});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Serializer } from '@metaplex-foundation/umi-serializers';
|
|
2
|
+
export type Base58EncodedAddress<TAddress extends string = string> = TAddress & {
|
|
3
|
+
readonly __base58EncodedAddress: unique symbol;
|
|
4
|
+
};
|
|
5
|
+
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
|
|
6
|
+
export declare function getBase58EncodedAddressCodec(config?: Readonly<{
|
|
7
|
+
description: string;
|
|
8
|
+
}>): Serializer<Base58EncodedAddress>;
|
|
9
|
+
export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number;
|
|
10
|
+
//# sourceMappingURL=base58.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAU,MAAM,sCAAsC,CAAC;AAElF,MAAM,MAAM,oBAAoB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,GAAG;IAC5E,QAAQ,CAAC,sBAAsB,EAAE,OAAO,MAAM,CAAC;CAClD,CAAC;AAEF,wBAAgB,4BAA4B,CACxC,4BAA4B,EAAE,MAAM,GACrC,OAAO,CAAC,4BAA4B,IAAI,oBAAoB,CAAC,OAAO,4BAA4B,CAAC,CAsBnG;AAED,wBAAgB,4BAA4B,CACxC,MAAM,CAAC,EAAE,QAAQ,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC,GACH,UAAU,CAAC,oBAAoB,CAAC,CAMlC;AAED,wBAAgB,iCAAiC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CASpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../../src/curve.ts"],"names":[],"mappings":"AAiBA,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAMxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Base58EncodedAddress } from './base58';
|
|
2
|
+
type PDAInput = Readonly<{
|
|
3
|
+
programAddress: Base58EncodedAddress;
|
|
4
|
+
seeds: Seed[];
|
|
5
|
+
}>;
|
|
6
|
+
type Seed = string | Uint8Array;
|
|
7
|
+
export declare function getProgramDerivedAddress({ programAddress, seeds }: PDAInput): Promise<Readonly<{
|
|
8
|
+
bumpSeed: number;
|
|
9
|
+
pda: Base58EncodedAddress;
|
|
10
|
+
}>>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=program-derived-address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-derived-address.d.ts","sourceRoot":"","sources":["../../src/program-derived-address.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAgC,MAAM,UAAU,CAAC;AAG9E,KAAK,QAAQ,GAAG,QAAQ,CAAC;IACrB,cAAc,EAAE,oBAAoB,CAAC;IACrC,KAAK,EAAE,IAAI,EAAE,CAAC;CACjB,CAAC,CAAC;AACH,KAAK,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;AA0ChC,wBAAsB,wBAAwB,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,QAAQ,GAAG,OAAO,CACxF,QAAQ,CAAC;IACL,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,oBAAoB,CAAC;CAC7B,CAAC,CACL,CAqBA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-key.d.ts","sourceRoot":"","sources":["../../src/public-key.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAgC,MAAM,UAAU,CAAC;AAE9E,wBAAsB,oCAAoC,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAS9G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../../../../src/vendor/noble/ed25519.ts"],"names":[],"mappings":"AAgFA,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAanE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@solana/addresses",
|
|
3
|
+
"version": "2.0.0-experimental.0108bc7",
|
|
4
|
+
"description": "Helpers for generating account addresses",
|
|
5
|
+
"exports": {
|
|
6
|
+
"browser": {
|
|
7
|
+
"import": "./dist/index.browser.js",
|
|
8
|
+
"require": "./dist/index.browser.cjs"
|
|
9
|
+
},
|
|
10
|
+
"node": {
|
|
11
|
+
"import": "./dist/index.node.js",
|
|
12
|
+
"require": "./dist/index.node.cjs"
|
|
13
|
+
},
|
|
14
|
+
"react-native": "./dist/index.native.js",
|
|
15
|
+
"types": "./dist/types/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"browser": {
|
|
18
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
19
|
+
"./dist/index.node.js": "./dist/index.browser.js"
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.node.cjs",
|
|
22
|
+
"module": "./dist/index.node.js",
|
|
23
|
+
"react-native": "./dist/index.native.js",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"files": [
|
|
27
|
+
"./dist/"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"keywords": [
|
|
31
|
+
"blockchain",
|
|
32
|
+
"solana",
|
|
33
|
+
"web3"
|
|
34
|
+
],
|
|
35
|
+
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/solana-labs/solana-web3.js"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "http://github.com/solana-labs/solana-web3.js/issues"
|
|
43
|
+
},
|
|
44
|
+
"browserslist": [
|
|
45
|
+
"supports bigint and not dead",
|
|
46
|
+
"maintained node versions"
|
|
47
|
+
],
|
|
48
|
+
"engine": {
|
|
49
|
+
"node": ">=17.4"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@metaplex-foundation/umi-serializers": "^0.8.5",
|
|
53
|
+
"@solana/assertions": "2.0.0-experimental.0108bc7"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@solana/eslint-config-solana": "^1.0.2",
|
|
57
|
+
"@swc/jest": "^0.2.27",
|
|
58
|
+
"@types/jest": "^29.5.3",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
61
|
+
"agadoo": "^3.0.0",
|
|
62
|
+
"eslint": "^8.45.0",
|
|
63
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
64
|
+
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
65
|
+
"jest": "^29.6.1",
|
|
66
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
67
|
+
"jest-runner-eslint": "^2.1.0",
|
|
68
|
+
"jest-runner-prettier": "^1.0.0",
|
|
69
|
+
"prettier": "^3.0.1",
|
|
70
|
+
"tsup": "7.2.0",
|
|
71
|
+
"typescript": "^5.1.6",
|
|
72
|
+
"version-from-git": "^1.1.1",
|
|
73
|
+
"build-scripts": "0.0.0",
|
|
74
|
+
"test-config": "0.0.0",
|
|
75
|
+
"tsconfig": "0.0.0"
|
|
76
|
+
},
|
|
77
|
+
"bundlewatch": {
|
|
78
|
+
"defaultCompression": "gzip",
|
|
79
|
+
"files": [
|
|
80
|
+
{
|
|
81
|
+
"path": "./dist/index*.js"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
|
|
87
|
+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
88
|
+
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
|
|
89
|
+
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
|
|
90
|
+
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
|
|
91
|
+
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
|
|
92
|
+
"test:treeshakability:browser": "agadoo dist/index.browser.js",
|
|
93
|
+
"test:treeshakability:native": "agadoo dist/index.node.js",
|
|
94
|
+
"test:treeshakability:node": "agadoo dist/index.native.js",
|
|
95
|
+
"test:typecheck": "tsc --noEmit",
|
|
96
|
+
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
|
|
97
|
+
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
|
|
98
|
+
}
|
|
99
|
+
}
|