@shelby-protocol/solana-kit 0.1.2-alpha.5 → 0.1.2-alpha.6
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/node/index.cjs +3 -1
- package/dist/node/index.d.cts +4 -1
- package/dist/node/index.d.ts +4 -1
- package/dist/node/index.mjs +3 -1
- package/dist/react/index.d.ts +15 -6
- package/dist/react/index.mjs +40 -15
- package/package.json +3 -2
package/dist/node/index.cjs
CHANGED
|
@@ -22,6 +22,8 @@ var _gasstationclient = require('@aptos-labs/gas-station-client');
|
|
|
22
22
|
|
|
23
23
|
// src/node/storageAccount.ts
|
|
24
24
|
var _node3 = require('@aptos-labs/derived-wallet-solana/node');
|
|
25
|
+
var ShelbyStorageAccount = class extends _node3.SolanaDerivedAccount {
|
|
26
|
+
};
|
|
25
27
|
|
|
26
28
|
// src/node/shelby.ts
|
|
27
29
|
var Shelby = class extends _node.ShelbyClient {
|
|
@@ -56,7 +58,7 @@ var Shelby = class extends _node.ShelbyClient {
|
|
|
56
58
|
* ```
|
|
57
59
|
*/
|
|
58
60
|
createStorageAccount(solanaKeypair, domain) {
|
|
59
|
-
return new (
|
|
61
|
+
return new ShelbyStorageAccount({ solanaKeypair, domain });
|
|
60
62
|
}
|
|
61
63
|
};
|
|
62
64
|
|
package/dist/node/index.d.cts
CHANGED
|
@@ -9,6 +9,9 @@ declare const Network: {
|
|
|
9
9
|
};
|
|
10
10
|
type Network = (typeof Network)[keyof typeof Network];
|
|
11
11
|
|
|
12
|
+
declare class ShelbyStorageAccount extends SolanaDerivedAccount {
|
|
13
|
+
}
|
|
14
|
+
|
|
12
15
|
interface ShelbyParams {
|
|
13
16
|
network: ShelbyNetwork;
|
|
14
17
|
connection: Connection;
|
|
@@ -44,7 +47,7 @@ declare class Shelby extends ShelbyClient {
|
|
|
44
47
|
* const storageAccount = shelbyClient.createStorageAccount(solanaKeypair, domain);
|
|
45
48
|
* ```
|
|
46
49
|
*/
|
|
47
|
-
createStorageAccount(solanaKeypair: Keypair, domain: string):
|
|
50
|
+
createStorageAccount(solanaKeypair: Keypair, domain: string): ShelbyStorageAccount;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
export { Network, Shelby, type ShelbyParams };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ declare const Network: {
|
|
|
9
9
|
};
|
|
10
10
|
type Network = (typeof Network)[keyof typeof Network];
|
|
11
11
|
|
|
12
|
+
declare class ShelbyStorageAccount extends SolanaDerivedAccount {
|
|
13
|
+
}
|
|
14
|
+
|
|
12
15
|
interface ShelbyParams {
|
|
13
16
|
network: ShelbyNetwork;
|
|
14
17
|
connection: Connection;
|
|
@@ -44,7 +47,7 @@ declare class Shelby extends ShelbyClient {
|
|
|
44
47
|
* const storageAccount = shelbyClient.createStorageAccount(solanaKeypair, domain);
|
|
45
48
|
* ```
|
|
46
49
|
*/
|
|
47
|
-
createStorageAccount(solanaKeypair: Keypair, domain: string):
|
|
50
|
+
createStorageAccount(solanaKeypair: Keypair, domain: string): ShelbyStorageAccount;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
export { Network, Shelby, type ShelbyParams };
|
package/dist/node/index.mjs
CHANGED
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
|
|
23
23
|
// src/node/storageAccount.ts
|
|
24
24
|
import { SolanaDerivedAccount } from "@aptos-labs/derived-wallet-solana/node";
|
|
25
|
+
var ShelbyStorageAccount = class extends SolanaDerivedAccount {
|
|
26
|
+
};
|
|
25
27
|
|
|
26
28
|
// src/node/shelby.ts
|
|
27
29
|
var Shelby = class extends ShelbyClient {
|
|
@@ -56,7 +58,7 @@ var Shelby = class extends ShelbyClient {
|
|
|
56
58
|
* ```
|
|
57
59
|
*/
|
|
58
60
|
createStorageAccount(solanaKeypair, domain) {
|
|
59
|
-
return new
|
|
61
|
+
return new ShelbyStorageAccount({ solanaKeypair, domain });
|
|
60
62
|
}
|
|
61
63
|
};
|
|
62
64
|
export {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { SolanaSigningWallet, useSolanaDerivedWallet } from '@aptos-labs/derived-wallet-solana/react';
|
|
3
|
-
import { Network as Network$1, InputGenerateTransactionPayloadData, InputTransactionPluginData, AnyRawTransaction, AccountAuthenticatorAbstraction, AccountAddress } from '@aptos-labs/ts-sdk';
|
|
1
|
+
import { Network as Network$1, InputEntryFunctionData, InputTransactionPluginData, AnyRawTransaction, AccountAuthenticatorAbstraction, AccountAddress } from '@aptos-labs/ts-sdk';
|
|
4
2
|
import { ShelbyClient } from '@shelby-protocol/sdk/browser';
|
|
3
|
+
import { SolanaSignInInput, SolanaSignInOutput } from '@solana/wallet-standard-features';
|
|
5
4
|
|
|
6
5
|
declare const Network: {
|
|
7
6
|
readonly SHELBYNET: Network$1.SHELBYNET;
|
|
8
7
|
};
|
|
9
8
|
type Network = (typeof Network)[keyof typeof Network];
|
|
10
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Minimal interface for Solana wallets that can sign.
|
|
12
|
+
* Compatible with @solana/wallet-adapter-react's useWallet() hook.
|
|
13
|
+
*/
|
|
14
|
+
interface SolanaWallet {
|
|
15
|
+
publicKey: string | null;
|
|
16
|
+
signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
|
|
17
|
+
signIn?: (input?: SolanaSignInInput) => Promise<SolanaSignInOutput>;
|
|
18
|
+
name?: string;
|
|
19
|
+
}
|
|
11
20
|
type SignTransactionInput = {
|
|
12
|
-
data:
|
|
21
|
+
data: InputEntryFunctionData;
|
|
13
22
|
};
|
|
14
23
|
type SubmitTransactionInput = {
|
|
15
24
|
transaction: AnyRawTransaction;
|
|
16
25
|
senderAuthenticator: AccountAuthenticatorAbstraction;
|
|
17
26
|
} & InputTransactionPluginData;
|
|
18
27
|
type SignAndSubmitTransactionInput = {
|
|
19
|
-
data:
|
|
28
|
+
data: InputEntryFunctionData;
|
|
20
29
|
} & InputTransactionPluginData;
|
|
21
30
|
interface UseStorageAccountParams {
|
|
22
31
|
client: ShelbyClient;
|
|
23
|
-
wallet:
|
|
32
|
+
wallet: SolanaWallet | null;
|
|
24
33
|
}
|
|
25
34
|
interface UseStorageAccountResult {
|
|
26
35
|
storageAccountAddress: AccountAddress | null;
|
package/dist/react/index.mjs
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// src/react/index.tsx
|
|
2
|
-
import {
|
|
3
|
-
useSolanaDerivedWallet as useSolanaDerivedWallet2
|
|
4
|
-
} from "@aptos-labs/derived-wallet-solana/react";
|
|
5
|
-
|
|
6
1
|
// src/common/constants.ts
|
|
7
2
|
import { defaultAuthenticationFunction } from "@aptos-labs/derived-wallet-solana";
|
|
8
3
|
import { Network as AptosNetwork } from "@aptos-labs/ts-sdk";
|
|
@@ -18,27 +13,58 @@ import {
|
|
|
18
13
|
|
|
19
14
|
// src/react/useStorageAccount.tsx
|
|
20
15
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from "@aptos-labs/ts-sdk";
|
|
16
|
+
defaultAuthenticationFunction as defaultAuthenticationFunction3,
|
|
17
|
+
SolanaDerivedPublicKey as SolanaDerivedPublicKey2,
|
|
18
|
+
signAptosTransactionWithSolana
|
|
19
|
+
} from "@aptos-labs/derived-wallet-solana";
|
|
26
20
|
import { UserResponseStatus } from "@aptos-labs/wallet-standard";
|
|
21
|
+
import { PublicKey } from "@solana/web3.js";
|
|
22
|
+
import { useMemo } from "react";
|
|
27
23
|
function useStorageAccount(params) {
|
|
28
24
|
const { client, wallet } = params;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
25
|
+
const domain = typeof window !== "undefined" ? window.location.host : void 0;
|
|
26
|
+
const derivedPublicKey = useMemo(() => {
|
|
27
|
+
if (!wallet?.publicKey || !domain) return null;
|
|
28
|
+
return new SolanaDerivedPublicKey2({
|
|
29
|
+
domain,
|
|
30
|
+
solanaPublicKey: new PublicKey(wallet.publicKey),
|
|
31
|
+
authenticationFunction: defaultAuthenticationFunction3
|
|
32
|
+
});
|
|
33
|
+
}, [wallet?.publicKey, domain]);
|
|
34
|
+
const storageAccountAddress = useMemo(
|
|
35
|
+
() => derivedPublicKey?.authKey().derivedAddress() ?? null,
|
|
36
|
+
[derivedPublicKey]
|
|
37
|
+
);
|
|
31
38
|
const signTransaction = async (params2) => {
|
|
32
39
|
if (!storageAccountAddress) {
|
|
33
40
|
throw new Error("Storage account address not found");
|
|
34
41
|
}
|
|
42
|
+
if (!wallet?.publicKey) {
|
|
43
|
+
throw new Error("Wallet not connected");
|
|
44
|
+
}
|
|
35
45
|
const rawTransaction = await client.aptos.transaction.build.simple({
|
|
36
46
|
sender: storageAccountAddress,
|
|
37
47
|
data: params2.data
|
|
38
48
|
});
|
|
39
|
-
|
|
49
|
+
if (!wallet) {
|
|
50
|
+
throw new Error("Wallet not connected");
|
|
51
|
+
}
|
|
52
|
+
if (!domain) {
|
|
53
|
+
throw new Error("Domain is required in the browser");
|
|
54
|
+
}
|
|
55
|
+
const response = await signAptosTransactionWithSolana({
|
|
56
|
+
solanaWallet: {
|
|
57
|
+
publicKey: new PublicKey(wallet.publicKey),
|
|
58
|
+
signMessage: wallet.signMessage,
|
|
59
|
+
signIn: wallet.signIn,
|
|
60
|
+
name: wallet.name ?? "Solana Wallet"
|
|
61
|
+
},
|
|
62
|
+
authenticationFunction: defaultAuthenticationFunction3,
|
|
63
|
+
rawTransaction,
|
|
64
|
+
domain
|
|
65
|
+
});
|
|
40
66
|
if (response.status !== UserResponseStatus.APPROVED || !("args" in response)) {
|
|
41
|
-
throw new Error("
|
|
67
|
+
throw new Error("User rejected the request.");
|
|
42
68
|
}
|
|
43
69
|
return {
|
|
44
70
|
authenticator: response.args,
|
|
@@ -75,6 +101,5 @@ function useStorageAccount(params) {
|
|
|
75
101
|
}
|
|
76
102
|
export {
|
|
77
103
|
Network,
|
|
78
|
-
useSolanaDerivedWallet2 as useSolanaDerivedWallet,
|
|
79
104
|
useStorageAccount
|
|
80
105
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shelby-protocol/solana-kit",
|
|
3
|
-
"version": "0.1.2-alpha.
|
|
3
|
+
"version": "0.1.2-alpha.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -47,10 +47,11 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@aptos-labs/derived-wallet-solana": "0.11.0-alpha.
|
|
50
|
+
"@aptos-labs/derived-wallet-solana": "0.11.0-alpha.4",
|
|
51
51
|
"@aptos-labs/gas-station-client": "^2.0.3",
|
|
52
52
|
"@aptos-labs/ts-sdk": "^5.1.1",
|
|
53
53
|
"@aptos-labs/wallet-standard": "^0.5.2",
|
|
54
|
+
"@solana/wallet-standard-features": "^1.3.0",
|
|
54
55
|
"@solana/web3.js": "^1.95.8",
|
|
55
56
|
"@shelby-protocol/sdk": "0.0.9"
|
|
56
57
|
},
|