@domino-sdk/relay 0.26.0 → 0.27.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/dist/authoring.d.ts +2 -2
- package/dist/browser.d.ts +181 -170
- package/dist/browser.js +3 -3
- package/dist/{chunk-S44XSDW2.js → chunk-D6AIUNSM.js} +4 -4
- package/dist/{chunk-7QICEKC2.js → chunk-M3R5V5WC.js} +34 -30
- package/dist/{chunk-MZFUQQDP.js → chunk-RVGO2CRA.js} +36 -9
- package/dist/index.d.ts +390 -390
- package/dist/index.js +8 -4
- package/dist/portal-proxy.js +1 -1
- package/dist/react/index.d.ts +27 -17
- package/dist/react/index.js +21 -12
- package/dist/{submission-input-Ckpb4sBv.d.ts → submission-input-CYyH_25w.d.ts} +41 -41
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
evmSigner,
|
|
9
9
|
solanaSigner,
|
|
10
10
|
walletStandardSolanaSigner
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-RVGO2CRA.js";
|
|
12
|
+
import "./chunk-D6AIUNSM.js";
|
|
13
13
|
import "./chunk-AKB266O5.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-M3R5V5WC.js";
|
|
15
15
|
import "./chunk-D6BX627V.js";
|
|
16
16
|
import "./chunk-IXLY3A7B.js";
|
|
17
17
|
export {
|
|
@@ -32,10 +32,10 @@ import {
|
|
|
32
32
|
walletConnectionSchema,
|
|
33
33
|
walletMessageChallengeSchema,
|
|
34
34
|
walletProofSchema,
|
|
35
|
-
|
|
35
|
+
walletSignInNetworksSchema,
|
|
36
36
|
walletSignatureSchema,
|
|
37
37
|
walletUnlinkInputSchema
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-M3R5V5WC.js";
|
|
39
39
|
import {
|
|
40
40
|
AVATAR_UPLOAD_LIMIT,
|
|
41
41
|
avatarUploadTypes,
|
|
@@ -2061,7 +2061,7 @@ function createRelayClient(options) {
|
|
|
2061
2061
|
),
|
|
2062
2062
|
email: z11.boolean(),
|
|
2063
2063
|
/** The wallet sign-in this project enabled; older servers omit it. */
|
|
2064
|
-
wallets:
|
|
2064
|
+
wallets: walletSignInNetworksSchema.default([]),
|
|
2065
2065
|
demo: z11.boolean()
|
|
2066
2066
|
})
|
|
2067
2067
|
),
|
|
@@ -2103,7 +2103,7 @@ function createRelayClient(options) {
|
|
|
2103
2103
|
),
|
|
2104
2104
|
/**
|
|
2105
2105
|
* Asks the signer for its address, signs the challenge and starts the session. Throws a
|
|
2106
|
-
* `RelayError` with status 403 when the project has not enabled this wallet
|
|
2106
|
+
* `RelayError` with status 403 when the project has not enabled this wallet family.
|
|
2107
2107
|
*/
|
|
2108
2108
|
signIn: async (signer) => {
|
|
2109
2109
|
const challenge = await request(
|
|
@@ -62,25 +62,32 @@ var solanaBalanceSchema = z2.object({
|
|
|
62
62
|
observedAt: z2.number().int().nonnegative()
|
|
63
63
|
}).strict();
|
|
64
64
|
var walletChainSchema = z2.enum(["solana", "eip155", "cosmos"]);
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"cosmos:
|
|
72
|
-
|
|
73
|
-
prefix: "tp",
|
|
74
|
-
name: "Provenance testnet"
|
|
65
|
+
var cosmosNetworkPattern = /^cosmos:[-_a-zA-Z0-9]{1,32}$/;
|
|
66
|
+
var cosmosNetworkSchema = z2.custom(
|
|
67
|
+
(value) => typeof value === "string" && cosmosNetworkPattern.test(value),
|
|
68
|
+
"Use a Cosmos network: cosmos:<chain ID>"
|
|
69
|
+
);
|
|
70
|
+
function cosmosChain(chain) {
|
|
71
|
+
if (typeof chain === "string" && !chain.startsWith("cosmos:")) {
|
|
72
|
+
throw new Error('Use a Cosmos network such as "cosmos:cosmoshub-4"');
|
|
75
73
|
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
const value = typeof chain === "string" ? { chainId: chain.slice("cosmos:".length) } : chain;
|
|
75
|
+
const network = `cosmos:${value.chainId}`;
|
|
76
|
+
if (!cosmosNetworkPattern.test(network)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"A Cosmos chain ID has 1 to 32 letters, digits, hyphens or underscores"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (value.chainInfo && value.chainInfo.chainId !== value.chainId) {
|
|
82
|
+
throw new Error("The chain info describes another chain ID");
|
|
83
|
+
}
|
|
84
|
+
return { ...value, network };
|
|
85
|
+
}
|
|
81
86
|
var solanaMainnet = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
82
87
|
var evmAddressSchema = z2.string().regex(/^0x[0-9a-fA-F]{40}$/);
|
|
83
|
-
var cosmosAddressSchema = z2.string().min(8).max(90).regex(
|
|
88
|
+
var cosmosAddressSchema = z2.string().min(8).max(90).regex(
|
|
89
|
+
/^(?:[a-z][a-z0-9]{0,82}1[02-9ac-hj-np-z]{38,}|[A-Z][A-Z0-9]{0,82}1[02-9AC-HJ-NP-Z]{38,})$/
|
|
90
|
+
);
|
|
84
91
|
var walletAddressInputSchema = z2.discriminatedUnion("chain", [
|
|
85
92
|
z2.object({ chain: z2.literal("solana"), address: solanaAddressSchema }).strict(),
|
|
86
93
|
z2.object({
|
|
@@ -135,25 +142,20 @@ async function walletAddressInput(signer) {
|
|
|
135
142
|
};
|
|
136
143
|
case "cosmos":
|
|
137
144
|
if (!signer.network) {
|
|
138
|
-
throw new Error("Choose
|
|
145
|
+
throw new Error("Choose the Cosmos chain for this wallet");
|
|
139
146
|
}
|
|
140
147
|
return { chain: "cosmos", network: signer.network, address };
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
150
|
var WALLETS_PER_CHAIN = 5;
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
"
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
var walletSignInFamilies = ["solana", "eip155", "cosmos"];
|
|
152
|
+
var walletSignInNetworkSchema = z2.union([z2.enum(walletSignInFamilies), z2.string().regex(cosmosNetworkPattern)]).transform(
|
|
153
|
+
(value) => value.startsWith("cosmos:") ? "cosmos" : value
|
|
154
|
+
);
|
|
155
|
+
var walletSignInNetworksSchema = z2.array(walletSignInNetworkSchema).transform(
|
|
156
|
+
(values) => walletSignInFamilies.filter((family) => values.includes(family))
|
|
157
|
+
);
|
|
150
158
|
function walletSignInNetwork(wallet) {
|
|
151
|
-
if (wallet.chain === "cosmos") {
|
|
152
|
-
if (!wallet.network) {
|
|
153
|
-
throw new Error("A Cosmos wallet belongs to its own network");
|
|
154
|
-
}
|
|
155
|
-
return wallet.network;
|
|
156
|
-
}
|
|
157
159
|
return wallet.chain;
|
|
158
160
|
}
|
|
159
161
|
function caip10(wallet, network) {
|
|
@@ -208,8 +210,8 @@ export {
|
|
|
208
210
|
walletProofSchema,
|
|
209
211
|
solanaBalanceSchema,
|
|
210
212
|
walletChainSchema,
|
|
211
|
-
cosmosNetworks,
|
|
212
213
|
cosmosNetworkSchema,
|
|
214
|
+
cosmosChain,
|
|
213
215
|
solanaMainnet,
|
|
214
216
|
evmAddressSchema,
|
|
215
217
|
cosmosAddressSchema,
|
|
@@ -220,7 +222,9 @@ export {
|
|
|
220
222
|
walletUnlinkInputSchema,
|
|
221
223
|
walletAddressInput,
|
|
222
224
|
WALLETS_PER_CHAIN,
|
|
225
|
+
walletSignInFamilies,
|
|
223
226
|
walletSignInNetworkSchema,
|
|
227
|
+
walletSignInNetworksSchema,
|
|
224
228
|
walletSignInNetwork,
|
|
225
229
|
caip10,
|
|
226
230
|
isWalletParticipantRoute,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D6AIUNSM.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
cosmosChain
|
|
6
|
+
} from "./chunk-M3R5V5WC.js";
|
|
7
7
|
|
|
8
8
|
// src/base58.ts
|
|
9
9
|
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -141,14 +141,40 @@ function walletStandardSolanaSigner(wallet) {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
var unknownChain = /no chain info|unknown chain|chain.{0,40}not (?:supported|found)/i;
|
|
145
|
+
function cosmosSigner(provider, chain, info = {}) {
|
|
146
|
+
const { chainId, chainInfo, network } = cosmosChain(chain);
|
|
147
|
+
const wallet = info.name ?? "This wallet";
|
|
148
|
+
async function enable() {
|
|
149
|
+
try {
|
|
150
|
+
await provider.enable(chainId);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
153
|
+
if (!unknownChain.test(message)) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
if (!chainInfo) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
`${wallet} doesn't know the Cosmos chain ${chainId}. Add the chain to the wallet, or pass its chainInfo so the wallet can suggest it.`,
|
|
159
|
+
{ cause: error }
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (!provider.experimentalSuggestChain) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`${wallet} doesn't know the Cosmos chain ${chainId} and cannot add chains. Add the chain to the wallet, or use a wallet that supports experimentalSuggestChain.`,
|
|
165
|
+
{ cause: error }
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
await provider.experimentalSuggestChain(chainInfo);
|
|
169
|
+
await provider.enable(chainId);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
146
172
|
return {
|
|
147
173
|
chain: "cosmos",
|
|
148
174
|
network,
|
|
149
175
|
name: info.name,
|
|
150
176
|
async address() {
|
|
151
|
-
await
|
|
177
|
+
await enable();
|
|
152
178
|
return (await provider.getKey(chainId)).bech32Address;
|
|
153
179
|
},
|
|
154
180
|
async sign(message, address) {
|
|
@@ -267,7 +293,8 @@ function discoverSolanaWallets() {
|
|
|
267
293
|
}
|
|
268
294
|
return wallets;
|
|
269
295
|
}
|
|
270
|
-
function discoverCosmosWallets(
|
|
296
|
+
function discoverCosmosWallets(chain) {
|
|
297
|
+
const { chainId } = cosmosChain(chain);
|
|
271
298
|
const target = injected();
|
|
272
299
|
if (!target) {
|
|
273
300
|
return [];
|
|
@@ -280,9 +307,9 @@ function discoverCosmosWallets(network) {
|
|
|
280
307
|
]) {
|
|
281
308
|
if (typeof provider?.signArbitrary === "function") {
|
|
282
309
|
wallets.push({
|
|
283
|
-
id: `${slug(name)}:${
|
|
310
|
+
id: `${slug(name)}:${chainId}`,
|
|
284
311
|
name,
|
|
285
|
-
signer: cosmosSigner(provider,
|
|
312
|
+
signer: cosmosSigner(provider, chain, { name })
|
|
286
313
|
});
|
|
287
314
|
}
|
|
288
315
|
}
|