@phantom/server-sdk 1.0.0-beta.1 → 1.0.0-beta.3
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/README.md +69 -2
- package/dist/index.d.ts +15 -3
- package/dist/index.js +102 -6
- package/dist/index.mjs +103 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -86,8 +86,8 @@ dotenv.config();
|
|
|
86
86
|
// Initialize the SDK
|
|
87
87
|
const sdk = new ServerSDK({
|
|
88
88
|
organizationId: process.env.ORGANIZATION_ID!,
|
|
89
|
+
appId: process.env.APP_ID!,
|
|
89
90
|
apiPrivateKey: process.env.PRIVATE_KEY!,
|
|
90
|
-
apiBaseUrl: process.env.API_URL!,
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// Create a wallet
|
|
@@ -121,6 +121,72 @@ console.log("Solana address:", solanaAddress);
|
|
|
121
121
|
console.log("Ethereum address:", ethereumAddress);
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
+
### Transaction Signing Methods
|
|
125
|
+
|
|
126
|
+
The Server SDK provides two methods for handling transactions:
|
|
127
|
+
|
|
128
|
+
1. **`signTransaction(params)`** - Signs a transaction without submitting it to the network
|
|
129
|
+
- Returns the signed transaction
|
|
130
|
+
- No network interaction
|
|
131
|
+
- Useful for offline signing or when you want to broadcast later
|
|
132
|
+
|
|
133
|
+
2. **`signAndSendTransaction(params)`** - Signs and submits the transaction to the network
|
|
134
|
+
- Returns both signed transaction and transaction hash
|
|
135
|
+
- Requires network connectivity
|
|
136
|
+
- Transaction is immediately broadcast to the blockchain
|
|
137
|
+
|
|
138
|
+
### Signing Only (No Network Submission)
|
|
139
|
+
|
|
140
|
+
#### Solana Transaction Signing
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { Transaction, SystemProgram, PublicKey } from "@solana/web3.js";
|
|
144
|
+
|
|
145
|
+
// Create a Solana transaction
|
|
146
|
+
const transaction = new Transaction().add(
|
|
147
|
+
SystemProgram.transfer({
|
|
148
|
+
fromPubkey: new PublicKey(solanaAddress),
|
|
149
|
+
toPubkey: new PublicKey(recipientAddress),
|
|
150
|
+
lamports: 1000000, // 0.001 SOL
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// Set transaction parameters
|
|
155
|
+
transaction.recentBlockhash = blockhash;
|
|
156
|
+
transaction.feePayer = new PublicKey(solanaAddress);
|
|
157
|
+
|
|
158
|
+
// Sign the transaction (without sending)
|
|
159
|
+
const signed = await sdk.signTransaction({
|
|
160
|
+
walletId: wallet.walletId,
|
|
161
|
+
transaction,
|
|
162
|
+
networkId: NetworkId.SOLANA_MAINNET,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
console.log("Signed transaction:", signed.rawTransaction);
|
|
166
|
+
// You can broadcast this transaction later using your own RPC client
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Ethereum Transaction Signing
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
// Viem transaction object
|
|
173
|
+
const evmTransaction = {
|
|
174
|
+
to: "0x742d35Cc6634C0532925a3b8D4C8db86fB5C4A7E",
|
|
175
|
+
value: 1000000000000000000n, // 1 ETH in wei
|
|
176
|
+
data: "0x",
|
|
177
|
+
gasLimit: 21000n,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const signed = await sdk.signTransaction({
|
|
181
|
+
walletId: wallet.walletId,
|
|
182
|
+
transaction: evmTransaction,
|
|
183
|
+
networkId: NetworkId.ETHEREUM_MAINNET,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
console.log("Signed transaction:", signed.rawTransaction);
|
|
187
|
+
// You can broadcast this signed transaction using your preferred method
|
|
188
|
+
```
|
|
189
|
+
|
|
124
190
|
### Signing and Sending Transactions
|
|
125
191
|
|
|
126
192
|
#### Solana - Native Web3.js Transaction Objects
|
|
@@ -279,7 +345,8 @@ For complete API documentation, visit **[docs.phantom.com/server-sdk](https://do
|
|
|
279
345
|
### Key Methods
|
|
280
346
|
|
|
281
347
|
- `createWallet(walletName?)` - Creates a new wallet
|
|
282
|
-
- `
|
|
348
|
+
- `signTransaction(params)` - Signs transactions without submitting to network
|
|
349
|
+
- `signAndSendTransaction(params)` - Signs and submits transactions to network
|
|
283
350
|
- `signMessage(params)` - Signs arbitrary messages
|
|
284
351
|
- `getWalletAddresses(walletId, derivationPaths?)` - Retrieves wallet addresses
|
|
285
352
|
- `getWallets(limit?, offset?)` - Lists all wallets with pagination
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AddressType, NetworkId, PhantomClient, Organization, GetWalletsResult, CreateWalletResult } from '@phantom/client';
|
|
2
|
-
export { CreateWalletResult, DerivationPath, GetWalletsResult, NetworkConfig, PhantomClient, SignedTransaction, Transaction, Wallet, deriveSubmissionConfig, generateKeyPair, getDerivationPathForNetwork, getNetworkConfig, getNetworkDescription, getNetworkIdsByChain, getSupportedNetworkIds, supportsTransactionSubmission } from '@phantom/client';
|
|
2
|
+
export { CreateWalletResult, DerivationPath, GetWalletsResult, NetworkConfig, PhantomClient, SignedTransaction, SignedTransactionResult, Transaction, Wallet, deriveSubmissionConfig, generateKeyPair, getDerivationPathForNetwork, getNetworkConfig, getNetworkDescription, getNetworkIdsByChain, getSupportedNetworkIds, supportsTransactionSubmission } from '@phantom/client';
|
|
3
3
|
import { ParsedSignatureResult, ParsedTransactionResult } from '@phantom/parsers';
|
|
4
4
|
export { ParsedMessage, ParsedSignatureResult, ParsedTransaction, ParsedTransactionResult, parseMessage, parseSignMessageResponse, parseTransactionResponse, parseTransactionToBase64Url } from '@phantom/parsers';
|
|
5
5
|
export { NetworkId } from '@phantom/constants';
|
|
@@ -13,7 +13,7 @@ interface WalletAddress {
|
|
|
13
13
|
interface ServerSDKConfig {
|
|
14
14
|
organizationId: string;
|
|
15
15
|
appId: string;
|
|
16
|
-
apiBaseUrl
|
|
16
|
+
apiBaseUrl?: string;
|
|
17
17
|
apiPrivateKey: string;
|
|
18
18
|
}
|
|
19
19
|
interface ServerSignMessageParams {
|
|
@@ -22,6 +22,12 @@ interface ServerSignMessageParams {
|
|
|
22
22
|
networkId: NetworkId;
|
|
23
23
|
derivationIndex?: number;
|
|
24
24
|
}
|
|
25
|
+
interface ServerSignTransactionParams {
|
|
26
|
+
walletId: string;
|
|
27
|
+
transaction: any;
|
|
28
|
+
networkId: NetworkId;
|
|
29
|
+
derivationIndex?: number;
|
|
30
|
+
}
|
|
25
31
|
interface ServerSignAndSendTransactionParams {
|
|
26
32
|
walletId: string;
|
|
27
33
|
transaction: any;
|
|
@@ -38,6 +44,12 @@ declare class ServerSDK {
|
|
|
38
44
|
* @returns Promise<ParsedSignatureResult> - Parsed signature with explorer URL
|
|
39
45
|
*/
|
|
40
46
|
signMessage(params: ServerSignMessageParams): Promise<ParsedSignatureResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Sign a transaction - supports various transaction formats and automatically parses them
|
|
49
|
+
* @param params - Transaction parameters with flexible transaction format
|
|
50
|
+
* @returns Promise<ParsedTransactionResult> - Parsed transaction result without hash
|
|
51
|
+
*/
|
|
52
|
+
signTransaction(params: ServerSignTransactionParams): Promise<ParsedTransactionResult>;
|
|
41
53
|
/**
|
|
42
54
|
* Sign and send a transaction - supports various transaction formats and automatically parses them
|
|
43
55
|
* @param params - Transaction parameters with flexible transaction format
|
|
@@ -56,4 +68,4 @@ declare class ServerSDK {
|
|
|
56
68
|
}[]>;
|
|
57
69
|
}
|
|
58
70
|
|
|
59
|
-
export { ServerSDK, ServerSDKConfig, ServerSignAndSendTransactionParams, ServerSignMessageParams, WalletAddress };
|
|
71
|
+
export { ServerSDK, ServerSDKConfig, ServerSignAndSendTransactionParams, ServerSignMessageParams, ServerSignTransactionParams, WalletAddress };
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
ApiKeyStamper: () => import_api_key_stamper2.ApiKeyStamper,
|
|
34
34
|
DerivationPath: () => import_client2.DerivationPath,
|
|
35
|
-
NetworkId: () =>
|
|
35
|
+
NetworkId: () => import_constants2.NetworkId,
|
|
36
36
|
PhantomClient: () => import_client2.PhantomClient,
|
|
37
37
|
ServerSDK: () => ServerSDK,
|
|
38
38
|
deriveSubmissionConfig: () => import_client2.deriveSubmissionConfig,
|
|
@@ -50,24 +50,102 @@ __export(src_exports, {
|
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(src_exports);
|
|
52
52
|
var import_client = require("@phantom/client");
|
|
53
|
+
var import_constants = require("@phantom/constants");
|
|
53
54
|
var import_api_key_stamper = require("@phantom/api-key-stamper");
|
|
54
55
|
var import_base64url = require("@phantom/base64url");
|
|
55
56
|
var import_bs58 = __toESM(require("bs58"));
|
|
57
|
+
|
|
58
|
+
// package.json
|
|
59
|
+
var package_default = {
|
|
60
|
+
name: "@phantom/server-sdk",
|
|
61
|
+
version: "1.0.0-beta.3",
|
|
62
|
+
description: "Server SDK for Phantom Wallet",
|
|
63
|
+
main: "dist/index.js",
|
|
64
|
+
module: "dist/index.mjs",
|
|
65
|
+
types: "dist/index.d.ts",
|
|
66
|
+
exports: {
|
|
67
|
+
".": {
|
|
68
|
+
import: "./dist/index.mjs",
|
|
69
|
+
require: "./dist/index.js",
|
|
70
|
+
types: "./dist/index.d.ts"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
scripts: {
|
|
74
|
+
"?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
|
|
75
|
+
"pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
|
|
76
|
+
build: "rimraf ./dist && tsup",
|
|
77
|
+
dev: "tsc --watch",
|
|
78
|
+
clean: "rm -rf dist",
|
|
79
|
+
test: "jest",
|
|
80
|
+
"test:watch": "jest --watch",
|
|
81
|
+
lint: "eslint src --ext .ts,.tsx",
|
|
82
|
+
"check-types": "yarn tsc --noEmit",
|
|
83
|
+
prettier: 'prettier --write "src/**/*.{ts,tsx}"'
|
|
84
|
+
},
|
|
85
|
+
devDependencies: {
|
|
86
|
+
"@types/jest": "^29.5.12",
|
|
87
|
+
"@types/node": "^20.11.0",
|
|
88
|
+
dotenv: "^16.4.1",
|
|
89
|
+
eslint: "8.53.0",
|
|
90
|
+
jest: "^29.7.0",
|
|
91
|
+
prettier: "^3.5.2",
|
|
92
|
+
rimraf: "^6.0.1",
|
|
93
|
+
"ts-jest": "^29.1.2",
|
|
94
|
+
tsup: "^6.7.0",
|
|
95
|
+
typescript: "^5.0.4"
|
|
96
|
+
},
|
|
97
|
+
dependencies: {
|
|
98
|
+
"@phantom/api-key-stamper": "workspace:^",
|
|
99
|
+
"@phantom/base64url": "workspace:^",
|
|
100
|
+
"@phantom/client": "workspace:^",
|
|
101
|
+
"@phantom/constants": "workspace:^",
|
|
102
|
+
"@phantom/parsers": "workspace:^",
|
|
103
|
+
bs58: "^6.0.0"
|
|
104
|
+
},
|
|
105
|
+
files: [
|
|
106
|
+
"dist"
|
|
107
|
+
],
|
|
108
|
+
publishConfig: {
|
|
109
|
+
directory: "_release/package"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/index.ts
|
|
56
114
|
var import_parsers = require("@phantom/parsers");
|
|
57
115
|
var import_client2 = require("@phantom/client");
|
|
58
|
-
var
|
|
116
|
+
var import_constants2 = require("@phantom/constants");
|
|
59
117
|
var import_api_key_stamper2 = require("@phantom/api-key-stamper");
|
|
60
118
|
var import_parsers2 = require("@phantom/parsers");
|
|
119
|
+
function getNodeVersion() {
|
|
120
|
+
if (typeof process !== "undefined" && process.version) {
|
|
121
|
+
return process.version;
|
|
122
|
+
}
|
|
123
|
+
return "unknown";
|
|
124
|
+
}
|
|
125
|
+
function getSdkVersion() {
|
|
126
|
+
return package_default.version || "unknown";
|
|
127
|
+
}
|
|
128
|
+
function createServerSdkHeaders(appId) {
|
|
129
|
+
return {
|
|
130
|
+
[import_constants.ANALYTICS_HEADERS.SDK_TYPE]: "server",
|
|
131
|
+
[import_constants.ANALYTICS_HEADERS.SDK_VERSION]: getSdkVersion(),
|
|
132
|
+
[import_constants.ANALYTICS_HEADERS.PLATFORM]: `node`,
|
|
133
|
+
[import_constants.ANALYTICS_HEADERS.PLATFORM_VERSION]: `${getNodeVersion()}`,
|
|
134
|
+
[import_constants.ANALYTICS_HEADERS.APP_ID]: appId
|
|
135
|
+
};
|
|
136
|
+
}
|
|
61
137
|
var ServerSDK = class {
|
|
62
138
|
constructor(config) {
|
|
63
139
|
this.config = config;
|
|
64
140
|
const stamper = new import_api_key_stamper.ApiKeyStamper({
|
|
65
141
|
apiSecretKey: config.apiPrivateKey
|
|
66
142
|
});
|
|
143
|
+
const headers = createServerSdkHeaders(config.appId);
|
|
67
144
|
this.client = new import_client.PhantomClient(
|
|
68
145
|
{
|
|
69
|
-
apiBaseUrl: config.apiBaseUrl,
|
|
70
|
-
organizationId: config.organizationId
|
|
146
|
+
apiBaseUrl: config.apiBaseUrl || import_constants.DEFAULT_WALLET_API_URL,
|
|
147
|
+
organizationId: config.organizationId,
|
|
148
|
+
headers
|
|
71
149
|
},
|
|
72
150
|
stamper
|
|
73
151
|
);
|
|
@@ -88,6 +166,22 @@ var ServerSDK = class {
|
|
|
88
166
|
const rawResponse = await this.client.signMessage(signMessageParams);
|
|
89
167
|
return (0, import_parsers.parseSignMessageResponse)(rawResponse, params.networkId);
|
|
90
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Sign a transaction - supports various transaction formats and automatically parses them
|
|
171
|
+
* @param params - Transaction parameters with flexible transaction format
|
|
172
|
+
* @returns Promise<ParsedTransactionResult> - Parsed transaction result without hash
|
|
173
|
+
*/
|
|
174
|
+
async signTransaction(params) {
|
|
175
|
+
const parsedTransaction = await (0, import_parsers.parseTransactionToBase64Url)(params.transaction, params.networkId);
|
|
176
|
+
const signTransactionParams = {
|
|
177
|
+
walletId: params.walletId,
|
|
178
|
+
transaction: parsedTransaction.base64url,
|
|
179
|
+
networkId: params.networkId,
|
|
180
|
+
derivationIndex: params.derivationIndex
|
|
181
|
+
};
|
|
182
|
+
const rawResponse = await this.client.signTransaction(signTransactionParams);
|
|
183
|
+
return await (0, import_parsers.parseTransactionResponse)(rawResponse.rawTransaction, params.networkId);
|
|
184
|
+
}
|
|
91
185
|
/**
|
|
92
186
|
* Sign and send a transaction - supports various transaction formats and automatically parses them
|
|
93
187
|
* @param params - Transaction parameters with flexible transaction format
|
|
@@ -105,10 +199,12 @@ var ServerSDK = class {
|
|
|
105
199
|
return await (0, import_parsers.parseTransactionResponse)(rawResponse.rawTransaction, params.networkId, rawResponse.hash);
|
|
106
200
|
}
|
|
107
201
|
createOrganization(name, keyPair) {
|
|
202
|
+
const headers = createServerSdkHeaders(this.config.appId);
|
|
108
203
|
const tempClient = new import_client.PhantomClient(
|
|
109
204
|
{
|
|
110
|
-
apiBaseUrl: this.config.apiBaseUrl,
|
|
111
|
-
organizationId: this.config.organizationId
|
|
205
|
+
apiBaseUrl: this.config.apiBaseUrl || import_constants.DEFAULT_WALLET_API_URL,
|
|
206
|
+
organizationId: this.config.organizationId,
|
|
207
|
+
headers
|
|
112
208
|
},
|
|
113
209
|
new import_api_key_stamper.ApiKeyStamper({
|
|
114
210
|
apiSecretKey: keyPair.secretKey
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,70 @@
|
|
|
2
2
|
import {
|
|
3
3
|
PhantomClient
|
|
4
4
|
} from "@phantom/client";
|
|
5
|
+
import {
|
|
6
|
+
ANALYTICS_HEADERS,
|
|
7
|
+
DEFAULT_WALLET_API_URL
|
|
8
|
+
} from "@phantom/constants";
|
|
5
9
|
import { ApiKeyStamper } from "@phantom/api-key-stamper";
|
|
6
10
|
import { base64urlEncode } from "@phantom/base64url";
|
|
7
11
|
import bs58 from "bs58";
|
|
12
|
+
|
|
13
|
+
// package.json
|
|
14
|
+
var package_default = {
|
|
15
|
+
name: "@phantom/server-sdk",
|
|
16
|
+
version: "1.0.0-beta.3",
|
|
17
|
+
description: "Server SDK for Phantom Wallet",
|
|
18
|
+
main: "dist/index.js",
|
|
19
|
+
module: "dist/index.mjs",
|
|
20
|
+
types: "dist/index.d.ts",
|
|
21
|
+
exports: {
|
|
22
|
+
".": {
|
|
23
|
+
import: "./dist/index.mjs",
|
|
24
|
+
require: "./dist/index.js",
|
|
25
|
+
types: "./dist/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
scripts: {
|
|
29
|
+
"?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
|
|
30
|
+
"pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
|
|
31
|
+
build: "rimraf ./dist && tsup",
|
|
32
|
+
dev: "tsc --watch",
|
|
33
|
+
clean: "rm -rf dist",
|
|
34
|
+
test: "jest",
|
|
35
|
+
"test:watch": "jest --watch",
|
|
36
|
+
lint: "eslint src --ext .ts,.tsx",
|
|
37
|
+
"check-types": "yarn tsc --noEmit",
|
|
38
|
+
prettier: 'prettier --write "src/**/*.{ts,tsx}"'
|
|
39
|
+
},
|
|
40
|
+
devDependencies: {
|
|
41
|
+
"@types/jest": "^29.5.12",
|
|
42
|
+
"@types/node": "^20.11.0",
|
|
43
|
+
dotenv: "^16.4.1",
|
|
44
|
+
eslint: "8.53.0",
|
|
45
|
+
jest: "^29.7.0",
|
|
46
|
+
prettier: "^3.5.2",
|
|
47
|
+
rimraf: "^6.0.1",
|
|
48
|
+
"ts-jest": "^29.1.2",
|
|
49
|
+
tsup: "^6.7.0",
|
|
50
|
+
typescript: "^5.0.4"
|
|
51
|
+
},
|
|
52
|
+
dependencies: {
|
|
53
|
+
"@phantom/api-key-stamper": "workspace:^",
|
|
54
|
+
"@phantom/base64url": "workspace:^",
|
|
55
|
+
"@phantom/client": "workspace:^",
|
|
56
|
+
"@phantom/constants": "workspace:^",
|
|
57
|
+
"@phantom/parsers": "workspace:^",
|
|
58
|
+
bs58: "^6.0.0"
|
|
59
|
+
},
|
|
60
|
+
files: [
|
|
61
|
+
"dist"
|
|
62
|
+
],
|
|
63
|
+
publishConfig: {
|
|
64
|
+
directory: "_release/package"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/index.ts
|
|
8
69
|
import {
|
|
9
70
|
parseMessage,
|
|
10
71
|
parseTransactionToBase64Url,
|
|
@@ -31,16 +92,36 @@ import {
|
|
|
31
92
|
parseSignMessageResponse as parseSignMessageResponse2,
|
|
32
93
|
parseTransactionResponse as parseTransactionResponse2
|
|
33
94
|
} from "@phantom/parsers";
|
|
95
|
+
function getNodeVersion() {
|
|
96
|
+
if (typeof process !== "undefined" && process.version) {
|
|
97
|
+
return process.version;
|
|
98
|
+
}
|
|
99
|
+
return "unknown";
|
|
100
|
+
}
|
|
101
|
+
function getSdkVersion() {
|
|
102
|
+
return package_default.version || "unknown";
|
|
103
|
+
}
|
|
104
|
+
function createServerSdkHeaders(appId) {
|
|
105
|
+
return {
|
|
106
|
+
[ANALYTICS_HEADERS.SDK_TYPE]: "server",
|
|
107
|
+
[ANALYTICS_HEADERS.SDK_VERSION]: getSdkVersion(),
|
|
108
|
+
[ANALYTICS_HEADERS.PLATFORM]: `node`,
|
|
109
|
+
[ANALYTICS_HEADERS.PLATFORM_VERSION]: `${getNodeVersion()}`,
|
|
110
|
+
[ANALYTICS_HEADERS.APP_ID]: appId
|
|
111
|
+
};
|
|
112
|
+
}
|
|
34
113
|
var ServerSDK = class {
|
|
35
114
|
constructor(config) {
|
|
36
115
|
this.config = config;
|
|
37
116
|
const stamper = new ApiKeyStamper({
|
|
38
117
|
apiSecretKey: config.apiPrivateKey
|
|
39
118
|
});
|
|
119
|
+
const headers = createServerSdkHeaders(config.appId);
|
|
40
120
|
this.client = new PhantomClient(
|
|
41
121
|
{
|
|
42
|
-
apiBaseUrl: config.apiBaseUrl,
|
|
43
|
-
organizationId: config.organizationId
|
|
122
|
+
apiBaseUrl: config.apiBaseUrl || DEFAULT_WALLET_API_URL,
|
|
123
|
+
organizationId: config.organizationId,
|
|
124
|
+
headers
|
|
44
125
|
},
|
|
45
126
|
stamper
|
|
46
127
|
);
|
|
@@ -61,6 +142,22 @@ var ServerSDK = class {
|
|
|
61
142
|
const rawResponse = await this.client.signMessage(signMessageParams);
|
|
62
143
|
return parseSignMessageResponse(rawResponse, params.networkId);
|
|
63
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Sign a transaction - supports various transaction formats and automatically parses them
|
|
147
|
+
* @param params - Transaction parameters with flexible transaction format
|
|
148
|
+
* @returns Promise<ParsedTransactionResult> - Parsed transaction result without hash
|
|
149
|
+
*/
|
|
150
|
+
async signTransaction(params) {
|
|
151
|
+
const parsedTransaction = await parseTransactionToBase64Url(params.transaction, params.networkId);
|
|
152
|
+
const signTransactionParams = {
|
|
153
|
+
walletId: params.walletId,
|
|
154
|
+
transaction: parsedTransaction.base64url,
|
|
155
|
+
networkId: params.networkId,
|
|
156
|
+
derivationIndex: params.derivationIndex
|
|
157
|
+
};
|
|
158
|
+
const rawResponse = await this.client.signTransaction(signTransactionParams);
|
|
159
|
+
return await parseTransactionResponse(rawResponse.rawTransaction, params.networkId);
|
|
160
|
+
}
|
|
64
161
|
/**
|
|
65
162
|
* Sign and send a transaction - supports various transaction formats and automatically parses them
|
|
66
163
|
* @param params - Transaction parameters with flexible transaction format
|
|
@@ -78,10 +175,12 @@ var ServerSDK = class {
|
|
|
78
175
|
return await parseTransactionResponse(rawResponse.rawTransaction, params.networkId, rawResponse.hash);
|
|
79
176
|
}
|
|
80
177
|
createOrganization(name, keyPair) {
|
|
178
|
+
const headers = createServerSdkHeaders(this.config.appId);
|
|
81
179
|
const tempClient = new PhantomClient(
|
|
82
180
|
{
|
|
83
|
-
apiBaseUrl: this.config.apiBaseUrl,
|
|
84
|
-
organizationId: this.config.organizationId
|
|
181
|
+
apiBaseUrl: this.config.apiBaseUrl || DEFAULT_WALLET_API_URL,
|
|
182
|
+
organizationId: this.config.organizationId,
|
|
183
|
+
headers
|
|
85
184
|
},
|
|
86
185
|
new ApiKeyStamper({
|
|
87
186
|
apiSecretKey: keyPair.secretKey
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/server-sdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Server SDK for Phantom Wallet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
|
|
17
17
|
"pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
|
|
18
|
-
"build": "rimraf ./dist && tsup
|
|
18
|
+
"build": "rimraf ./dist && tsup",
|
|
19
19
|
"dev": "tsc --watch",
|
|
20
20
|
"clean": "rm -rf dist",
|
|
21
21
|
"test": "jest",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"typescript": "^5.0.4"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@phantom/api-key-stamper": "^1.0.0-beta.
|
|
41
|
-
"@phantom/base64url": "^1.0.0-beta.
|
|
42
|
-
"@phantom/client": "^1.0.0-beta.
|
|
43
|
-
"@phantom/constants": "^1.0.0-beta.
|
|
44
|
-
"@phantom/parsers": "^1.0.0-beta.
|
|
40
|
+
"@phantom/api-key-stamper": "^1.0.0-beta.3",
|
|
41
|
+
"@phantom/base64url": "^1.0.0-beta.3",
|
|
42
|
+
"@phantom/client": "^1.0.0-beta.3",
|
|
43
|
+
"@phantom/constants": "^1.0.0-beta.3",
|
|
44
|
+
"@phantom/parsers": "^1.0.0-beta.3",
|
|
45
45
|
"bs58": "^6.0.0"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|