@tempoxyz/id 0.0.0-pr-496.sha-e625357 → 0.0.0-pr-349.sha-e95088c
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/AccessKey.d.ts.map +1 -1
- package/dist/AccessKey.js +11 -5
- package/dist/AccessKey.js.map +1 -1
- package/dist/TempoAccount.d.ts +26 -20
- package/dist/TempoAccount.d.ts.map +1 -1
- package/dist/TempoAccount.js +48 -15
- package/dist/TempoAccount.js.map +1 -1
- package/dist/internal/accessKey.d.ts +5 -0
- package/dist/internal/accessKey.d.ts.map +1 -1
- package/dist/internal/accessKey.js +11 -0
- package/dist/internal/accessKey.js.map +1 -1
- package/dist/internal/relayRoute.d.ts +55 -0
- package/dist/internal/relayRoute.d.ts.map +1 -0
- package/dist/internal/relayRoute.js +67 -0
- package/dist/internal/relayRoute.js.map +1 -0
- package/dist/internal/signer.d.ts.map +1 -1
- package/dist/internal/signer.js +3 -3
- package/dist/internal/signer.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/relay.d.ts +73 -0
- package/dist/plugins/relay.d.ts.map +1 -0
- package/dist/plugins/relay.js +84 -0
- package/dist/plugins/relay.js.map +1 -0
- package/dist/plugins/viem.d.ts +7 -0
- package/dist/plugins/viem.d.ts.map +1 -1
- package/dist/plugins/viem.js +12 -7
- package/dist/plugins/viem.js.map +1 -1
- package/dist/wagmi/index.js +2 -2
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +2 -2
- package/src/AccessKey.ts +14 -5
- package/src/TempoAccount.ts +68 -26
- package/src/internal/accessKey.ts +14 -0
- package/src/internal/relayRoute.ts +113 -0
- package/src/internal/signer.ts +6 -2
- package/src/plugins/index.ts +1 -0
- package/src/plugins/relay.ts +141 -0
- package/src/plugins/viem.ts +18 -6
- package/src/wagmi/index.ts +2 -2
package/dist/AccessKey.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessKey.d.ts","sourceRoot":"","sources":["../src/AccessKey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAa,KAAK,aAAa,EAAE,MAAM,IAAI,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"AccessKey.d.ts","sourceRoot":"","sources":["../src/AccessKey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAa,KAAK,aAAa,EAAE,MAAM,IAAI,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,OAAO,EAA2B,MAAM,YAAY,CAAA;AAE7D;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI;IACvD,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAA;IACxB,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAA;IAChB,0DAA0D;IAC1D,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAA;CACvC,GAAG,QAAQ,CAAA;AAEZ,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,KAAK,CACxB;IACE,+DAA+D;IAC/D,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,UAAU,CAAA;CAChD,GACD;IACE,kFAAkF;IAClF,UAAU,EAAE,GAAG,CAAC,GAAG,CAAA;CACpB,GACD,EAAE,CACL,CAAA;AAED,+EAA+E;AAC/E,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAkB,IAAI,sCAAqC;IAE3D,cAEC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,WAGrC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAClD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GACzB,SAAS,CAAC,OAAO,CAAC,CAOpB;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,KAAK,KAAK,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI;QAC5C,iDAAiD;QACjD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAA;QACxB,kEAAkE;QAClE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QAC7B,0DAA0D;QAC1D,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,CAAA;KACvC,GAAG,QAAQ,CAAA;CACb;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,SAAS,EACd,OAAO,GAAE,SAAS,CAAC,OAAY,GAC9B,OAAO,CAAC,gBAAgB,CA0B1B;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAK,OAAO,GAAG;QACb,2GAA2G;QAC3G,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAA;KACxC,CAAA;CACF"}
|
package/dist/AccessKey.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { PublicKey } from 'ox';
|
|
6
6
|
import { KeyAuthorization } from 'ox/tempo';
|
|
7
|
-
import { Account } from 'viem/tempo';
|
|
7
|
+
import { Account, KeyAuthorizationManager } from 'viem/tempo';
|
|
8
8
|
/** `toAccount` received an access key without material, and no `accessKey`. */
|
|
9
9
|
export class AccessKeyRequiredError extends Error {
|
|
10
10
|
name = 'AccessKey.AccessKeyRequiredError';
|
|
@@ -54,10 +54,16 @@ export function from(value) {
|
|
|
54
54
|
*/
|
|
55
55
|
export function toAccount(key, options = {}) {
|
|
56
56
|
const { accessKey } = options;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const keyAuthorization = KeyAuthorization.fromRpc(key.keyAuthorization);
|
|
58
|
+
const keyAuthorizationManager = KeyAuthorizationManager.memory();
|
|
59
|
+
// The memory manager stores synchronously, so the authorization is in place before the account
|
|
60
|
+
// is returned.
|
|
61
|
+
void keyAuthorizationManager.set({
|
|
62
|
+
accessKey: keyAuthorization.address,
|
|
63
|
+
address: key.account,
|
|
64
|
+
chainId: Number(keyAuthorization.chainId),
|
|
65
|
+
}, keyAuthorization);
|
|
66
|
+
const access = { access: key.account, keyAuthorizationManager };
|
|
61
67
|
if (key.keyPair)
|
|
62
68
|
return Account.fromWebCryptoP256(key.keyPair, access);
|
|
63
69
|
if (key.privateKey)
|
package/dist/AccessKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessKey.js","sourceRoot":"","sources":["../src/AccessKey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA0B,SAAS,EAAsB,MAAM,IAAI,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"AccessKey.js","sourceRoot":"","sources":["../src/AccessKey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA0B,SAAS,EAAsB,MAAM,IAAI,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AA4B7D,+EAA+E;AAC/E,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7B,IAAI,GAAG,kCA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,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,uBAAuB,EAAE,CAAA;IAE/D,IAAI,GAAG,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACtE,IAAI,GAAG,CAAC,UAAU;QAAE,OAAO,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IACxE,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,sBAAsB,EAAE,CAAA;IAClD,gGAAgG;IAChG,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,GAAG,MAAM;QACT,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;QACjD,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;KACnE,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/TempoAccount.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
* One of a user's Tempo Accounts, as a Viem configurable account (TIP-1107) with Tempo ID's fields.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
1
|
+
import { AccountConfig } from 'ox/tempo';
|
|
5
2
|
import { Account } from 'viem/tempo';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
/** A configuration that does not derive the account's address. */
|
|
4
|
+
export declare class AddressMismatchError extends Error {
|
|
5
|
+
readonly name = "TempoAccount.AddressMismatchError";
|
|
6
|
+
/** The address that the configuration derives. */
|
|
7
|
+
readonly derived: `0x${string}`;
|
|
8
|
+
constructor(options: AddressMismatchError.Options);
|
|
9
|
+
}
|
|
10
|
+
export declare namespace AddressMismatchError {
|
|
11
|
+
type Options = {
|
|
12
|
+
/** The address of the account. */
|
|
13
|
+
address: `0x${string}`;
|
|
14
|
+
/** The address that the configuration derives. */
|
|
15
|
+
derived: `0x${string}`;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
19
|
* One of the user's Tempo Accounts: the Viem account that `Account.fromConfig` from `viem/tempo`
|
|
14
20
|
* returns, with the account's keys, its signer of key authorizations, and its realm. On a chain with
|
|
@@ -63,11 +69,10 @@ export declare namespace TempoAccount {
|
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
|
-
* Rebuilds a Tempo Account from the value of {@link serialize}, with no request
|
|
67
|
-
*
|
|
68
|
-
* `
|
|
69
|
-
*
|
|
70
|
-
* A later version keeps `address`, since its configuration no longer derives it.
|
|
72
|
+
* Rebuilds a Tempo Account from the value of {@link serialize}, with no request. On a chain with
|
|
73
|
+
* configurable accounts, a passkey among `keys` that holds a credential signs as an owner, through
|
|
74
|
+
* `getFn`. Throws {@link AddressMismatchError} for a version 0 configuration that does not derive
|
|
75
|
+
* `address`. A later version keeps `address`, since its configuration no longer derives it.
|
|
71
76
|
*
|
|
72
77
|
* @example
|
|
73
78
|
* ```ts
|
|
@@ -95,11 +100,12 @@ export declare namespace deserialize {
|
|
|
95
100
|
* ```
|
|
96
101
|
*/
|
|
97
102
|
export declare function from(value: TempoAccount): TempoAccount;
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
/** A Tempo Account as JSON, which {@link serialize} returns and {@link deserialize} rebuilds. */
|
|
104
|
+
export type Serialized = {
|
|
105
|
+
/** The account's address. */
|
|
106
|
+
address: `0x${string}`;
|
|
107
|
+
/** The account's configuration. Absent where the account is not configurable. */
|
|
108
|
+
config?: AccountConfig.Rpc | undefined;
|
|
103
109
|
/** The owner keys, as for `TempoAccount.keys`. */
|
|
104
110
|
keys: readonly TempoAccount.Key[];
|
|
105
111
|
/** Who signs the account's key authorizations, as for `TempoAccount.owner`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TempoAccount.d.ts","sourceRoot":"","sources":["../src/TempoAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TempoAccount.d.ts","sourceRoot":"","sources":["../src/TempoAccount.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,kEAAkE;AAClE,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAkB,IAAI,uCAAsC;IAC5D,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IAE/B,YAAY,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAKhD;CACF;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB,CAAC;IAC5C,KAAK,OAAO,GAAG;QACb,kCAAkC;QAClC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;QACtB,kDAAkD;QAClD,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;KACvB,CAAA;CACF;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,mBAAmB,GAAG;IACvD;;;OAGG;IACH,IAAI,EAAE,SAAS,YAAY,CAAC,GAAG,EAAE,CAAA;IACjC;;;;;OAKG;IACH,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IACzD,2EAA2E;IAC3E,KAAK,EAAE;QACL,+EAA+E;QAC/E,EAAE,EAAE,MAAM,CAAA;QACV,8CAA8C;QAC9C,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IACpC,wCAAwC;IACxC,KAAK,GAAG,GAAG;QACT,+BAA+B;QAC/B,OAAO,EAAE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;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAQ3D"}
|
package/dist/TempoAccount.js
CHANGED
|
@@ -2,18 +2,24 @@
|
|
|
2
2
|
* One of a user's Tempo Accounts, as a Viem configurable account (TIP-1107) with Tempo ID's fields.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
+
import { Address } from 'ox';
|
|
6
|
+
import { AccountConfig } from 'ox/tempo';
|
|
5
7
|
import { Account } from 'viem/tempo';
|
|
8
|
+
/** A configuration that does not derive the account's address. */
|
|
9
|
+
export class AddressMismatchError extends Error {
|
|
10
|
+
name = 'TempoAccount.AddressMismatchError';
|
|
11
|
+
/** The address that the configuration derives. */
|
|
12
|
+
derived;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(`Invalid account configuration: it derives ${options.derived}, not ${options.address}. Read the account again.`);
|
|
15
|
+
this.derived = options.derived;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
6
18
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Rebuilds a Tempo Account from the value of {@link serialize}, with no request, through Viem's
|
|
13
|
-
* `Account.deserialize`. On a chain with configurable accounts, a passkey among `keys` whose
|
|
14
|
-
* `credential` derives one of the configuration's owners signs as that owner, through `getFn`.
|
|
15
|
-
* Throws {@link AddressMismatchError} for a version 0 configuration that does not derive `address`.
|
|
16
|
-
* A later version keeps `address`, since its configuration no longer derives it.
|
|
19
|
+
* Rebuilds a Tempo Account from the value of {@link serialize}, with no request. On a chain with
|
|
20
|
+
* configurable accounts, a passkey among `keys` that holds a credential signs as an owner, through
|
|
21
|
+
* `getFn`. Throws {@link AddressMismatchError} for a version 0 configuration that does not derive
|
|
22
|
+
* `address`. A later version keeps `address`, since its configuration no longer derives it.
|
|
17
23
|
*
|
|
18
24
|
* @example
|
|
19
25
|
* ```ts
|
|
@@ -22,9 +28,31 @@ export const AddressMismatchError = Account.AddressMismatchError;
|
|
|
22
28
|
*/
|
|
23
29
|
export function deserialize(value, options = {}) {
|
|
24
30
|
const { address, config, keys, owner, realm } = value;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
const viem = (() => {
|
|
32
|
+
if (!config)
|
|
33
|
+
return Account.fromConfig(address);
|
|
34
|
+
const owners = config.owners.map((entry) => {
|
|
35
|
+
const credential = keys.find((key) => Address.isEqual(key.address, entry.owner))?.credential;
|
|
36
|
+
return {
|
|
37
|
+
owner: credential
|
|
38
|
+
? Account.fromWebAuthnP256(credential, {
|
|
39
|
+
getFn: options.getFn,
|
|
40
|
+
rpId: credential.rpId,
|
|
41
|
+
})
|
|
42
|
+
: entry.owner,
|
|
43
|
+
weight: entry.weight,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
const { salt, threshold } = config;
|
|
47
|
+
const version = BigInt(config.version);
|
|
48
|
+
// Viem derives the address of a version 0 configuration, and refuses an address beside it.
|
|
49
|
+
if (version === 0n)
|
|
50
|
+
return Account.fromConfig({ owners, salt, threshold });
|
|
51
|
+
return Account.fromConfig({ address, owners, salt, threshold, version });
|
|
52
|
+
})();
|
|
53
|
+
if (!Address.isEqual(viem.address, address))
|
|
54
|
+
throw new AddressMismatchError({ address, derived: viem.address });
|
|
55
|
+
return { ...viem, keys, owner, realm };
|
|
28
56
|
}
|
|
29
57
|
/**
|
|
30
58
|
* Instantiates a {@link TempoAccount}.
|
|
@@ -52,7 +80,12 @@ export function from(value) {
|
|
|
52
80
|
* ```
|
|
53
81
|
*/
|
|
54
82
|
export function serialize(account) {
|
|
55
|
-
|
|
56
|
-
|
|
83
|
+
return {
|
|
84
|
+
address: account.address,
|
|
85
|
+
...(account.config ? { config: AccountConfig.toRpc(account.config) } : {}),
|
|
86
|
+
keys: account.keys,
|
|
87
|
+
owner: account.owner,
|
|
88
|
+
realm: account.realm,
|
|
89
|
+
};
|
|
57
90
|
}
|
|
58
91
|
//# sourceMappingURL=TempoAccount.js.map
|
package/dist/TempoAccount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TempoAccount.js","sourceRoot":"","sources":["../src/TempoAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC
|
|
1
|
+
{"version":3,"file":"TempoAccount.js","sourceRoot":"","sources":["../src/TempoAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,kEAAkE;AAClE,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC3B,IAAI,GAAG,mCAAmC,CAAA;IAC5D,kDAAkD;IACzC,OAAO,CAAe;IAE/B,YAAY,OAAqC;QAC/C,KAAK,CACH,6CAA6C,OAAO,CAAC,OAAO,SAAS,OAAO,CAAC,OAAO,2BAA2B,CAChH,CAAA;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;CACF;AAmED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACzB,KAAiB,EACjB,OAAO,GAAwB,EAAE;IAEjC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;IAErD,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE;QACjB,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACzC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnC,OAAO,CAAC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,OAAO,CAAC,OAAO;QACxB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAA;AACH,CAAC"}
|
|
@@ -5,6 +5,11 @@ import type * as AccessKey from '../AccessKey.js';
|
|
|
5
5
|
* secp256k1 access key.
|
|
6
6
|
*/
|
|
7
7
|
export declare function resolve(accessKey: Account.Account | undefined): Promise<resolve.ReturnType>;
|
|
8
|
+
/**
|
|
9
|
+
* Rebuilds an access key that {@link resolve} generated from its material. Returns `undefined` for the
|
|
10
|
+
* empty material of the app's own access key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function restore(material: AccessKey.Material): resolve.ReturnType | undefined;
|
|
8
13
|
export declare namespace resolve {
|
|
9
14
|
type ReturnType = {
|
|
10
15
|
/** A Viem account that signs with the access key. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessKey.d.ts","sourceRoot":"","sources":["../../src/internal/accessKey.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAa,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAEjD;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,GACrC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAgB7B;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,KAAK,UAAU,GAAG;QAChB,qDAAqD;QACrD,SAAS,EAAE,OAAO,CAAC,OAAO,CAAA;QAC1B,kGAAkG;QAClG,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAA;KAC7B,CAAA;CACF"}
|
|
1
|
+
{"version":3,"file":"accessKey.d.ts","sourceRoot":"","sources":["../../src/internal/accessKey.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAa,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAEjD;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,GACrC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAgB7B;AAED;;;GAGG;AACH,wBAAgB,OAAO,CACrB,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAC3B,OAAO,CAAC,UAAU,GAAG,SAAS,CAMhC;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,KAAK,UAAU,GAAG;QAChB,qDAAqD;QACrD,SAAS,EAAE,OAAO,CAAC,OAAO,CAAA;QAC1B,kGAAkG;QAClG,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAA;KAC7B,CAAA;CACF"}
|
|
@@ -24,4 +24,15 @@ export async function resolve(accessKey) {
|
|
|
24
24
|
material: { privateKey },
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Rebuilds an access key that {@link resolve} generated from its material. Returns `undefined` for the
|
|
29
|
+
* empty material of the app's own access key.
|
|
30
|
+
*/
|
|
31
|
+
export function restore(material) {
|
|
32
|
+
if (material.keyPair)
|
|
33
|
+
return { accessKey: Account.fromWebCryptoP256(material.keyPair), material };
|
|
34
|
+
if (material.privateKey)
|
|
35
|
+
return { accessKey: Account.fromSecp256k1(material.privateKey), material };
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
27
38
|
//# sourceMappingURL=accessKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessKey.js","sourceRoot":"","sources":["../../src/internal/accessKey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EA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CAAA;IACH,CAAC;IAED,MAAM,UAAU,GAAG,SAAS,CAAC,gBAAgB,EAAE,CAAA;IAC/C,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC;QAC5C,QAAQ,EAAE,EAAE,UAAU,EAAE;KACzB,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CACrB,QAA4B;IAE5B,IAAI,QAAQ,CAAC,OAAO;QAClB,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAA;IAC7E,IAAI,QAAQ,CAAC,UAAU;QACrB,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAA;IAC5E,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's relay route, which pays the fees of its pages' transactions: its handler on the app's
|
|
3
|
+
* server, which the `relay` plugin serves, and the page's transport, which the `viem` plugin's
|
|
4
|
+
* `relay` option builds. The entries of the package do not export it.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type HttpTransportConfig, type Transport } from 'viem';
|
|
8
|
+
import { Relay } from 'viem/tempo';
|
|
9
|
+
/**
|
|
10
|
+
* Returns the handler of the relay route. With `apiKey`, it forwards each request to the Tempo
|
|
11
|
+
* API's `/rpc/sponsor` of `chainId`, whose sponsor pays the fees. Otherwise it serves Viem's relay
|
|
12
|
+
* of `Relay.create` with the options. The handler checks no caller, so any caller that reaches the
|
|
13
|
+
* route spends the fee payer's balance, within the limits of the API key or of the relay's plugins.
|
|
14
|
+
*/
|
|
15
|
+
export declare function handler(options: handler.Options): handler.ReturnType;
|
|
16
|
+
export declare namespace handler {
|
|
17
|
+
type Options = Options.TempoApi | Options.Viem;
|
|
18
|
+
namespace Options {
|
|
19
|
+
/** The options of the Tempo API mode, whose sponsor pays the fees. */
|
|
20
|
+
type TempoApi = {
|
|
21
|
+
/** The app's Tempo API key, with the `rpc-relay:sponsor` scope. Its sponsor pays the fees. */
|
|
22
|
+
apiKey: string;
|
|
23
|
+
/** The origin of the Tempo API. Defaults to `https://api.tempo.xyz`. */
|
|
24
|
+
apiUrl?: string | undefined;
|
|
25
|
+
/** The chain whose transactions the route relays. */
|
|
26
|
+
chainId: number;
|
|
27
|
+
};
|
|
28
|
+
/** The options of the Viem relay mode: those of Viem's `Relay.create`. */
|
|
29
|
+
type Viem = Relay.create.Options & {
|
|
30
|
+
apiKey?: undefined;
|
|
31
|
+
/** The chain whose transactions the route relays. */
|
|
32
|
+
chainId: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The handler: a function of the Fetch API from a request to its response. */
|
|
36
|
+
type ReturnType = {
|
|
37
|
+
/** Serves `request`, and returns its response. */
|
|
38
|
+
fetch: (request: Request) => Promise<Response>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns a transport that sends the sponsorship requests of a transaction to the relay route at
|
|
43
|
+
* `url`, and every other request to `rpc`. Viem's `withRelay` selects the requests: a fill, and a
|
|
44
|
+
* raw transaction without its fee payer's signature.
|
|
45
|
+
*/
|
|
46
|
+
export declare function transport(options: transport.Options): Transport;
|
|
47
|
+
export declare namespace transport {
|
|
48
|
+
type Options = HttpTransportConfig & {
|
|
49
|
+
/** The transport of every request but a sponsorship's. Defaults to `http()`, the chain's own RPC. */
|
|
50
|
+
rpc?: Transport | undefined;
|
|
51
|
+
/** The URL of the app's relay route, such as `/api/relay`. */
|
|
52
|
+
url: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=relayRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relayRoute.d.ts","sourceRoot":"","sources":["../../src/internal/relayRoute.ts"],"names":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+1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's relay route, which pays the fees of its pages' transactions: its handler on the app's
|
|
3
|
+
* server, which the `relay` plugin serves, and the page's transport, which the `viem` plugin's
|
|
4
|
+
* `relay` option builds. The entries of the package do not export it.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { http } from 'viem';
|
|
8
|
+
import { Relay, withRelay } from 'viem/tempo';
|
|
9
|
+
/**
|
|
10
|
+
* Returns the handler of the relay route. With `apiKey`, it forwards each request to the Tempo
|
|
11
|
+
* API's `/rpc/sponsor` of `chainId`, whose sponsor pays the fees. Otherwise it serves Viem's relay
|
|
12
|
+
* of `Relay.create` with the options. The handler checks no caller, so any caller that reaches the
|
|
13
|
+
* route spends the fee payer's balance, within the limits of the API key or of the relay's plugins.
|
|
14
|
+
*/
|
|
15
|
+
export function handler(options) {
|
|
16
|
+
if (options.apiKey !== undefined)
|
|
17
|
+
return tempoApi(options);
|
|
18
|
+
const { apiKey: _apiKey, chainId, ...relayOptions } = options;
|
|
19
|
+
// `Relay.create` takes `client` and `getClient` in separate overloads, and no overload takes
|
|
20
|
+
// their union, which the options hold.
|
|
21
|
+
const relay = Relay.create(relayOptions);
|
|
22
|
+
// Viem's fill names no chain, so each request relays on the route's chain.
|
|
23
|
+
return { fetch: (request) => relay.fetch(request, { chainId }) };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a transport that sends the sponsorship requests of a transaction to the relay route at
|
|
27
|
+
* `url`, and every other request to `rpc`. Viem's `withRelay` selects the requests: a fill, and a
|
|
28
|
+
* raw transaction without its fee payer's signature.
|
|
29
|
+
*/
|
|
30
|
+
export function transport(options) {
|
|
31
|
+
const { rpc = http(), url, ...httpOptions } = options;
|
|
32
|
+
return withRelay(rpc, http(url, httpOptions));
|
|
33
|
+
}
|
|
34
|
+
/** Returns the handler of the Tempo API mode, which forwards each request with the API key. */
|
|
35
|
+
function tempoApi(options) {
|
|
36
|
+
const { apiKey, apiUrl = 'https://api.tempo.xyz', chainId } = options;
|
|
37
|
+
return {
|
|
38
|
+
async fetch(request) {
|
|
39
|
+
if (request.method !== 'POST')
|
|
40
|
+
return new Response(null, { headers: { allow: 'POST' }, status: 405 });
|
|
41
|
+
const response = await fetch(new URL(`/rpc/sponsor/${chainId}`, apiUrl), {
|
|
42
|
+
body: await request.text(),
|
|
43
|
+
headers: {
|
|
44
|
+
'content-type': 'application/json',
|
|
45
|
+
'tempo-api-key': apiKey,
|
|
46
|
+
},
|
|
47
|
+
method: 'POST',
|
|
48
|
+
}).catch(() => undefined);
|
|
49
|
+
if (!response)
|
|
50
|
+
return Response.json({
|
|
51
|
+
error: {
|
|
52
|
+
code: -32002,
|
|
53
|
+
data: { reason: 'temporarily_unavailable' },
|
|
54
|
+
message: 'Sponsor unavailable: the request to the Tempo API failed. Retry later.',
|
|
55
|
+
},
|
|
56
|
+
id: null,
|
|
57
|
+
jsonrpc: '2.0',
|
|
58
|
+
}, { status: 503 });
|
|
59
|
+
// A Node `fetch` decodes a compressed body, so the response forwards none of its encoding.
|
|
60
|
+
return new Response(response.body, {
|
|
61
|
+
headers: { 'content-type': 'application/json' },
|
|
62
|
+
status: response.status,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=relayRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relayRoute.js","sourceRoot":"","sources":["../../src/internal/relayRoute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAA4C,MAAM,MAAM,CAAA;AACrE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAwB;IAC9C,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1D,MAAM,EAAE,M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E,CAAC,SAAS,CAAC,CAAA;YACzB,IAAI,CAAC,QAAQ;gBACX,OAAO,QAAQ,CAAC,IAAI,CAClB;oBACE,KAAK,EAAE;wBACL,IAAI,EAAE,CAAC,KAAK;wBACZ,IAAI,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE;wBAC3C,OAAO,EACL,wEAAwE;qBAC3E;oBACD,EAAE,EAAE,IAAI;oBACR,OAAO,EAAE,KAAK;iBACf,EACD,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAA;YACH,2FAA2F;YAC3F,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;gBACjC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/internal/signer.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/internal/signer.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,OAAO,EAEL,KAAK,MAAM,EAIZ,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAA;AAG7C;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,CAAC,OAAO,EACxB,OAAO,EAAE,WAAW,CAAC,OAAO,GAC3B,YAAY,GAAG,SAAS,CAwC1B;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,KAAK,OAAO,GAAG;QACb;;;;WAIG;QACH,WAAW,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAA;QAC7D,yEAAyE;QACzE,OAAO,EAAE,MAAM,CAAA;QACf;;;;WAIG;QACH,UAAU,CAAC,EACP,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAC3D,SAAS,CAAA;QACb;;;;WAIG;QACH,MAAM,EAAE,WAAW,GAAG,UAAU,CAAA;KACjC,CAAA;CACF;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,YAAY,GAAG,SAAS,GAAG,YAAY,CA4BtE"}
|
package/dist/internal/signer.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { Address } from 'ox';
|
|
8
|
-
import {} from 'viem';
|
|
8
|
+
import { hashMessage, hashTypedData, } from 'viem';
|
|
9
9
|
import { toAccount } from 'viem/accounts';
|
|
10
10
|
import { Account } from 'viem/tempo';
|
|
11
11
|
import * as Actions from '../Actions.js';
|
|
@@ -116,8 +116,8 @@ function ownerSigners(config, options) {
|
|
|
116
116
|
if (weight < Number(configuration.threshold))
|
|
117
117
|
return undefined;
|
|
118
118
|
return {
|
|
119
|
-
signMessage: (parameters) => account.
|
|
120
|
-
signTypedData: (typedData) => account.
|
|
119
|
+
signMessage: (parameters) => account.sign({ hash: hashMessage(parameters.message) }),
|
|
120
|
+
signTypedData: (typedData) => account.sign({ hash: hashTypedData(typedData) }),
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
// On a chain without configurable accounts, a passkey of the user's whose key is the account's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/internal/signer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"signer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AA;IACb,CAAC,CAAA;IACD,OAAO;QACL,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE,CAC1B,OAAO,CAAC,OAAO;aACZ,WAAW,CAAC,MAAM,EAAE;YACnB,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,UAAU,CAAC,OAAO;SAC5B,CAAC;aACD,KAAK,CAAC,OAAO,CAAC;QACnB,aAAa,EAAE,CAAC,SAAS,EAAE,EAAE,CAC3B,OAAO,CAAC,OAAO;aACZ,aAAa,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;aACtE,KAAK,CAAC,OAAO,CAAC;KACpB,CAAA;AACH,CAAC"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -18,5 +18,6 @@ export { email } from './email.js';
|
|
|
18
18
|
export { funding } from './funding.js';
|
|
19
19
|
export { passkey } from './passkey.js';
|
|
20
20
|
export { redirect } from './redirect.js';
|
|
21
|
+
export { relay } from './relay.js';
|
|
21
22
|
export { viem } from './viem.js';
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -18,5 +18,6 @@ export { email } from './email.js';
|
|
|
18
18
|
export { funding } from './funding.js';
|
|
19
19
|
export { passkey } from './passkey.js';
|
|
20
20
|
export { redirect } from './redirect.js';
|
|
21
|
+
export { relay } from './relay.js';
|
|
21
22
|
export { viem } from './viem.js';
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin of an app's relay route: `tempoId.relay`, the handler on the app's server that pays the
|
|
3
|
+
* fees of its pages' transactions, through the Tempo API's sponsor or the app's own fee payer.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type LocalAccount } from 'viem';
|
|
7
|
+
import { Relay } from 'viem/tempo';
|
|
8
|
+
import * as RelayRoute from '../internal/relayRoute.js';
|
|
9
|
+
import * as Plugin from '../Plugin.js';
|
|
10
|
+
import { viem } from './viem.js';
|
|
11
|
+
/**
|
|
12
|
+
* Returns the plugin of the app's relay route, which adds `tempoId.relay`: a handler of the Fetch
|
|
13
|
+
* API that the app's server serves at the URL of the page's `viem({ relay })`.
|
|
14
|
+
*
|
|
15
|
+
* With `apiKey`, the handler forwards each request to the Tempo API's `/rpc/sponsor`, whose sponsor
|
|
16
|
+
* pays the fees. Otherwise it serves Viem's relay over the chains and transports of the `viem`
|
|
17
|
+
* plugin, and `account` pays the fees through `Relay.feePayer`. Without a `viem` plugin in
|
|
18
|
+
* `plugins`, it adds the Viem client itself, as `viem()` does.
|
|
19
|
+
*
|
|
20
|
+
* The handler checks no caller, so any caller that reaches the route spends the fee payer's balance,
|
|
21
|
+
* within the limits of the API key or of the relay's plugins.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const tempoId = Id.create({
|
|
26
|
+
* clientId: 'https://app.example',
|
|
27
|
+
* plugins: [relay({ account: privateKeyToAccount(env.FEE_PAYER_KEY) })],
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* app.post('/api/relay', (c) => tempoId.relay.fetch(c.req.raw))
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function relay(options: relay.Options): Plugin.Plugin<"relay", unknown, relay.Members>;
|
|
34
|
+
export declare namespace relay {
|
|
35
|
+
type Options = Options.TempoApi | Options.Viem;
|
|
36
|
+
namespace Options {
|
|
37
|
+
/** The options of the Tempo API mode, whose sponsor pays the fees. */
|
|
38
|
+
type TempoApi = {
|
|
39
|
+
account?: undefined;
|
|
40
|
+
/** The app's Tempo API key, with the `rpc-relay:sponsor` scope. Its sponsor pays the fees. */
|
|
41
|
+
apiKey: string;
|
|
42
|
+
/** The origin of the Tempo API. Defaults to `https://api.tempo.xyz`. */
|
|
43
|
+
apiUrl?: string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The chain whose transactions the route relays. A fill names no chain, so a route serves one
|
|
46
|
+
* chain. Defaults to the instance's `chainId`.
|
|
47
|
+
*/
|
|
48
|
+
chainId?: number | undefined;
|
|
49
|
+
};
|
|
50
|
+
/** The options of the Viem relay mode: those of Viem's `Relay.handleRequest`, and `account`. */
|
|
51
|
+
type Viem = Relay.handleRequest.Options & {
|
|
52
|
+
/** The fee payer, which signs for the fees of each transaction through `Relay.feePayer`. */
|
|
53
|
+
account?: LocalAccount | undefined;
|
|
54
|
+
apiKey?: undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The chain of a request that names none, such as Viem's fill. Defaults to the instance's
|
|
57
|
+
* `chainId`.
|
|
58
|
+
*/
|
|
59
|
+
chainId?: number | undefined;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The members that the plugin adds to the instance: `relay`, and the `viem` plugin's members when
|
|
64
|
+
* `plugins` holds no `viem` plugin.
|
|
65
|
+
*/
|
|
66
|
+
type Members = {
|
|
67
|
+
/** The handler of the app's relay route. */
|
|
68
|
+
relay: RelayRoute.handler.ReturnType;
|
|
69
|
+
/** The Viem client, as the `viem` plugin adds it. */
|
|
70
|
+
viem: viem.Namespace;
|
|
71
|
+
} & viem.Actions;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/plugins/relay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAY,IAAI,EAAE,MAAM,WAAW,CAAA;AAE1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,kDA+D3C;AAED,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,KAAK,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAA;IAE9C,UAAU,OAAO,CAAC;QAChB,sEAAsE;QACtE,KAAK,QAAQ,GAAG;YACd,OAAO,CAAC,EAAE,SAAS,CAAA;YACnB,8FAA8F;YAC9F,MAAM,EAAE,MAAM,CAAA;YACd,wEAAwE;YACxE,MAAM,CA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