passkey-kit 0.5.0 → 0.5.1
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/package.json +4 -2
- package/packages/sac-sdk/README.md +54 -0
- package/packages/sac-sdk/package.json +18 -0
- package/packages/sac-sdk/src/index.ts +573 -0
- package/packages/sac-sdk/tsconfig.json +98 -0
- package/packages/sac-sdk/types/index.d.ts +527 -0
- package/src/base.ts +1 -1
- package/src/index.ts +2 -1
- package/src/sac.ts +94 -0
- package/tsconfig.json +8 -5
- package/types/base.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/sac.d.ts +12 -0
- package/types/src/base.d.ts +0 -9
- package/types/src/index.d.ts +0 -3
- package/types/src/kit.d.ts +0 -53
- package/types/tests/index.d.ts +0 -1
package/src/sac.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SorobanRpc } from "@stellar/stellar-sdk"
|
|
2
|
+
import { Client as SacClient } from 'sac-sdk'
|
|
3
|
+
|
|
4
|
+
export class SACClient {
|
|
5
|
+
public networkPassphrase: string
|
|
6
|
+
public rpcUrl: string
|
|
7
|
+
public rpc: SorobanRpc.Server
|
|
8
|
+
|
|
9
|
+
constructor(options: {
|
|
10
|
+
networkPassphrase: string,
|
|
11
|
+
rpcUrl: string
|
|
12
|
+
}) {
|
|
13
|
+
const { networkPassphrase, rpcUrl } = options
|
|
14
|
+
|
|
15
|
+
this.networkPassphrase = networkPassphrase
|
|
16
|
+
this.rpcUrl = rpcUrl
|
|
17
|
+
this.rpc = new SorobanRpc.Server(rpcUrl)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public getSACClient(SACContractId: string) {
|
|
21
|
+
return new SacClient({
|
|
22
|
+
contractId: SACContractId,
|
|
23
|
+
networkPassphrase: this.networkPassphrase,
|
|
24
|
+
rpcUrl: this.rpcUrl
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// switch (command) {
|
|
28
|
+
// case SacCommands.Allowance:
|
|
29
|
+
// return sac.allowance(args)
|
|
30
|
+
// case SacCommands.Authorized:
|
|
31
|
+
// return sac.authorized(args)
|
|
32
|
+
// case SacCommands.Approve:
|
|
33
|
+
// return sac.approve(args)
|
|
34
|
+
// case SacCommands.Balance:
|
|
35
|
+
// return sac.balance(args)
|
|
36
|
+
// case SacCommands.Burn:
|
|
37
|
+
// return sac.burn(args)
|
|
38
|
+
// case SacCommands.BurnFrom:
|
|
39
|
+
// return sac.burn_from(args)
|
|
40
|
+
// case SacCommands.Clawback:
|
|
41
|
+
// return sac.clawback(args)
|
|
42
|
+
// case SacCommands.Decimals:
|
|
43
|
+
// return sac.decimals(args)
|
|
44
|
+
// case SacCommands.Mint:
|
|
45
|
+
// return sac.mint(args)
|
|
46
|
+
// case SacCommands.Name:
|
|
47
|
+
// return sac.name(args)
|
|
48
|
+
// case SacCommands.SetAdmin:
|
|
49
|
+
// return sac.set_admin(args)
|
|
50
|
+
// case SacCommands.Admin:
|
|
51
|
+
// return sac.admin(args)
|
|
52
|
+
// case SacCommands.SetAuthorized:
|
|
53
|
+
// return sac.set_authorized(args)
|
|
54
|
+
// case SacCommands.Symbol:
|
|
55
|
+
// return sac.symbol(args)
|
|
56
|
+
// case SacCommands.Transfer:
|
|
57
|
+
// return sac.transfer(args)
|
|
58
|
+
// case SacCommands.TransferFrom:
|
|
59
|
+
// return sac.transfer_from(args)
|
|
60
|
+
// default:
|
|
61
|
+
// throw new Error('Invalid command')
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
// const { SAC, from, to, amount, fee = 0 } = args
|
|
65
|
+
// const txn = new TransactionBuilder(mockSource, {
|
|
66
|
+
// fee: fee.toString(),
|
|
67
|
+
// networkPassphrase: import.meta.env.VITE_networkPassphrase
|
|
68
|
+
// })
|
|
69
|
+
// .addOperation(Operation.invokeContractFunction({
|
|
70
|
+
// contract: SAC,
|
|
71
|
+
// function: 'transfer',
|
|
72
|
+
// args: [
|
|
73
|
+
// nativeToScVal(from, { type: 'address' }),
|
|
74
|
+
// nativeToScVal(to, { type: 'address' }),
|
|
75
|
+
// nativeToScVal(amount, { type: 'i128' })
|
|
76
|
+
// ],
|
|
77
|
+
// }))
|
|
78
|
+
// .setTimeout(5 * 60)
|
|
79
|
+
// .build()
|
|
80
|
+
|
|
81
|
+
// const sim = await rpc.simulateTransaction(txn)
|
|
82
|
+
|
|
83
|
+
// if (
|
|
84
|
+
// SorobanRpc.Api.isSimulationError(sim)
|
|
85
|
+
// || SorobanRpc.Api.isSimulationRestore(sim)
|
|
86
|
+
// ) throw sim
|
|
87
|
+
|
|
88
|
+
// return {
|
|
89
|
+
// txn,
|
|
90
|
+
// sim,
|
|
91
|
+
// built: SorobanRpc.assembleTransaction(txn, sim).build()
|
|
92
|
+
// }
|
|
93
|
+
}
|
|
94
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"outDir": "./types",
|
|
4
|
-
|
|
5
4
|
// Enable latest features
|
|
6
5
|
"target": "ESNext",
|
|
7
6
|
"module": "ESNext",
|
|
8
7
|
"moduleDetection": "force",
|
|
9
|
-
|
|
10
8
|
// Bundler mode
|
|
11
9
|
"moduleResolution": "node",
|
|
12
10
|
"allowImportingTsExtensions": true,
|
|
13
11
|
"verbatimModuleSyntax": true,
|
|
14
12
|
"declaration": true,
|
|
15
13
|
"emitDeclarationOnly": true,
|
|
16
|
-
|
|
17
14
|
// Best practices
|
|
18
15
|
"strict": true,
|
|
19
16
|
"skipLibCheck": true,
|
|
20
17
|
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
|
|
22
18
|
// Some stricter flags (disabled by default)
|
|
23
19
|
"noUnusedLocals": false,
|
|
24
20
|
"noUnusedParameters": false,
|
|
25
21
|
"noPropertyAccessFromIndexSignature": false,
|
|
26
22
|
"strictNullChecks": true,
|
|
27
23
|
},
|
|
28
|
-
"exclude": [
|
|
24
|
+
"exclude": [
|
|
25
|
+
"./bun_tests",
|
|
26
|
+
"./contracts",
|
|
27
|
+
"./demo",
|
|
28
|
+
"./packages",
|
|
29
|
+
"./types",
|
|
30
|
+
"./zephyr",
|
|
31
|
+
]
|
|
29
32
|
}
|
package/types/base.d.ts
CHANGED
package/types/index.d.ts
CHANGED
package/types/sac.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SorobanRpc } from "@stellar/stellar-sdk";
|
|
2
|
+
import { Client as SacClient } from 'sac-sdk';
|
|
3
|
+
export declare class SACClient {
|
|
4
|
+
networkPassphrase: string;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
rpc: SorobanRpc.Server;
|
|
7
|
+
constructor(options: {
|
|
8
|
+
networkPassphrase: string;
|
|
9
|
+
rpcUrl: string;
|
|
10
|
+
});
|
|
11
|
+
getSACClient(SACContractId: string): SacClient;
|
|
12
|
+
}
|
package/types/src/base.d.ts
DELETED
package/types/src/index.d.ts
DELETED
package/types/src/kit.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Client as PasskeyClient } from 'passkey-kit-sdk';
|
|
2
|
-
import { Client as FactoryClient } from 'passkey-factory-sdk';
|
|
3
|
-
import { Networks, xdr, Transaction, SorobanRpc } from '@stellar/stellar-sdk';
|
|
4
|
-
import { Buffer } from 'buffer';
|
|
5
|
-
import { PasskeyBase } from './base';
|
|
6
|
-
type GetContractIdFunction = (keyId: string) => Promise<string>;
|
|
7
|
-
export declare class PasskeyKit extends PasskeyBase {
|
|
8
|
-
keyId: string | undefined;
|
|
9
|
-
keyExpired: boolean | undefined;
|
|
10
|
-
wallet: PasskeyClient | undefined;
|
|
11
|
-
factory: FactoryClient;
|
|
12
|
-
networkPassphrase: Networks;
|
|
13
|
-
rpcUrl: string;
|
|
14
|
-
rpc: SorobanRpc.Server;
|
|
15
|
-
constructor(options: {
|
|
16
|
-
rpcUrl: string;
|
|
17
|
-
launchtubeUrl?: string;
|
|
18
|
-
launchtubeJwt?: string;
|
|
19
|
-
networkPassphrase: string;
|
|
20
|
-
factoryContractId: string;
|
|
21
|
-
});
|
|
22
|
-
createWallet(name: string, user: string): Promise<{
|
|
23
|
-
keyId: Buffer;
|
|
24
|
-
contractId: string;
|
|
25
|
-
xdr: string;
|
|
26
|
-
}>;
|
|
27
|
-
createKey(name: string, user: string): Promise<{
|
|
28
|
-
keyId: Buffer;
|
|
29
|
-
publicKey: Buffer;
|
|
30
|
-
}>;
|
|
31
|
-
connectWallet(opts: {
|
|
32
|
-
keyId?: string | Uint8Array;
|
|
33
|
-
getContractId?: GetContractIdFunction;
|
|
34
|
-
}): Promise<{
|
|
35
|
-
keyId: Buffer;
|
|
36
|
-
contractId: string;
|
|
37
|
-
}>;
|
|
38
|
-
signAuthEntry(entry: xdr.SorobanAuthorizationEntry, options?: {
|
|
39
|
-
keyId?: 'any' | string | Uint8Array;
|
|
40
|
-
ledgersToLive?: number;
|
|
41
|
-
}): Promise<xdr.SorobanAuthorizationEntry>;
|
|
42
|
-
signAuthEntries(entries: xdr.SorobanAuthorizationEntry[], options?: {
|
|
43
|
-
keyId?: 'any' | string | Uint8Array;
|
|
44
|
-
ledgersToLive?: number;
|
|
45
|
-
}): Promise<xdr.SorobanAuthorizationEntry[]>;
|
|
46
|
-
sign(txn: Transaction | string, options?: {
|
|
47
|
-
keyId?: 'any' | string | Uint8Array;
|
|
48
|
-
ledgersToLive?: number;
|
|
49
|
-
}): Promise<string>;
|
|
50
|
-
private getPublicKeyObject;
|
|
51
|
-
private convertEcdsaSignatureAsnToCompact;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
package/types/tests/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|