@jpool/bond-sdk 0.0.1-next.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/.env +6 -0
- package/.release-it.cjs +1 -0
- package/README.md +126 -0
- package/dist/index.d.mts +866 -0
- package/dist/index.d.ts +866 -0
- package/dist/index.js +1205 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1193 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -0
- package/src/client.ts +568 -0
- package/src/common.ts +2 -0
- package/src/config.ts +35 -0
- package/src/helpers.ts +7 -0
- package/src/idl/jbond.json +707 -0
- package/src/index.ts +8 -0
- package/src/types/index.ts +96 -0
- package/src/types/jbond.ts +713 -0
- package/src/utils/wallet.ts +45 -0
- package/tsconfig.json +39 -0
- package/tsup.config.ts +19 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Keypair, PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js'
|
|
2
|
+
|
|
3
|
+
function isVersionedTransaction(tx: Transaction | VersionedTransaction): tx is VersionedTransaction {
|
|
4
|
+
return 'version' in tx
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type Wallet = {
|
|
8
|
+
publicKey: PublicKey
|
|
9
|
+
signMessage?: (message: Uint8Array) => Promise<Uint8Array>
|
|
10
|
+
signTransaction: <T extends Transaction | VersionedTransaction>(tx: T) => Promise<T>
|
|
11
|
+
signAllTransactions: <T extends Transaction | VersionedTransaction>(txs: T[]) => Promise<T[]>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class NodeWallet implements Wallet {
|
|
15
|
+
constructor(readonly payer: Keypair) {}
|
|
16
|
+
|
|
17
|
+
async signTransaction<T extends Transaction | VersionedTransaction>(
|
|
18
|
+
tx: T,
|
|
19
|
+
): Promise<T> {
|
|
20
|
+
if (isVersionedTransaction(tx)) {
|
|
21
|
+
tx.sign([this.payer])
|
|
22
|
+
} else {
|
|
23
|
+
tx.partialSign(this.payer)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return tx
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async signAllTransactions<T extends Transaction | VersionedTransaction>(
|
|
30
|
+
txs: T[],
|
|
31
|
+
): Promise<T[]> {
|
|
32
|
+
return txs.map((t) => {
|
|
33
|
+
if (isVersionedTransaction(t)) {
|
|
34
|
+
t.sign([this.payer])
|
|
35
|
+
} else {
|
|
36
|
+
t.partialSign(this.payer)
|
|
37
|
+
}
|
|
38
|
+
return t
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get publicKey(): PublicKey {
|
|
43
|
+
return this.payer.publicKey
|
|
44
|
+
}
|
|
45
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Default",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "esnext",
|
|
6
|
+
"lib": [
|
|
7
|
+
"dom",
|
|
8
|
+
"esnext"
|
|
9
|
+
],
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"module": "esnext",
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"strict": true,
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"noImplicitAny": false,
|
|
18
|
+
"useUnknownInCatchVariables": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"declarationMap": true,
|
|
21
|
+
"importHelpers": false,
|
|
22
|
+
"inlineSources": false,
|
|
23
|
+
"outDir": "dist",
|
|
24
|
+
"sourceMap": true,
|
|
25
|
+
"esModuleInterop": true,
|
|
26
|
+
"forceConsistentCasingInFileNames": true,
|
|
27
|
+
"isolatedModules": true,
|
|
28
|
+
"skipLibCheck": true
|
|
29
|
+
},
|
|
30
|
+
"include": [
|
|
31
|
+
"src",
|
|
32
|
+
"types",
|
|
33
|
+
"tests"
|
|
34
|
+
],
|
|
35
|
+
"exclude": [
|
|
36
|
+
"node_modules",
|
|
37
|
+
"dist"
|
|
38
|
+
]
|
|
39
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Options } from 'tsup'
|
|
2
|
+
import { defineConfig } from 'tsup'
|
|
3
|
+
|
|
4
|
+
export default defineConfig((options: Options) => ({
|
|
5
|
+
entry: ['src/index.ts'],
|
|
6
|
+
format: ['cjs', 'esm'],
|
|
7
|
+
platform: 'neutral',
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
cjsInterop: true,
|
|
10
|
+
shims: true,
|
|
11
|
+
dts: true,
|
|
12
|
+
treeshake: true,
|
|
13
|
+
external: [
|
|
14
|
+
/@project-serum\/.*/,
|
|
15
|
+
/@coral-xyz\/.*/,
|
|
16
|
+
/@solana\/.*/,
|
|
17
|
+
],
|
|
18
|
+
...options,
|
|
19
|
+
}))
|