@fogo/sessions-sdk 0.0.1 → 0.0.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/cjs/index.js +9 -7
- package/esm/index.js +9 -7
- package/package.json +2 -2
package/cjs/index.js
CHANGED
|
@@ -27,8 +27,8 @@ const establishSession = async (options) => {
|
|
|
27
27
|
buildStartSessionInstruction(options, sessionKey, tokenInfo),
|
|
28
28
|
]);
|
|
29
29
|
const result = await options.adapter.sendTransaction(sessionKey, [
|
|
30
|
-
intentInstruction,
|
|
31
30
|
...buildCreateAssociatedTokenAccountInstructions(options, tokenInfo),
|
|
31
|
+
intentInstruction,
|
|
32
32
|
startSessionInstruction,
|
|
33
33
|
]);
|
|
34
34
|
switch (result.type) {
|
|
@@ -121,12 +121,14 @@ const buildMessage = async (body) => new TextEncoder().encode([
|
|
|
121
121
|
const serializeKV = (data) => Object.entries(data)
|
|
122
122
|
.map(([key, value]) => [key, ":", value.startsWith("\n") ? "" : " ", value].join(""))
|
|
123
123
|
.join("\n");
|
|
124
|
-
const serializeTokenList = (tokens) => tokens
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
const serializeTokenList = (tokens) => tokens.length === 0
|
|
125
|
+
? "\n"
|
|
126
|
+
: tokens
|
|
127
|
+
.values()
|
|
128
|
+
.filter(({ amount }) => amount > 0n)
|
|
129
|
+
.map(({ symbolOrMint, amount, decimals }) => `\n-${symbolOrMint.type === SymbolOrMintType.Symbol ? symbolOrMint.symbol : symbolOrMint.mint.toBase58()}: ${amountToString(amount, decimals)}`)
|
|
130
|
+
.toArray()
|
|
131
|
+
.join("");
|
|
130
132
|
const amountToString = (amount, decimals) => {
|
|
131
133
|
const asStr = amount.toString();
|
|
132
134
|
const whole = asStr.length > decimals ? asStr.slice(0, asStr.length - decimals) : "0";
|
package/esm/index.js
CHANGED
|
@@ -22,8 +22,8 @@ export const establishSession = async (options) => {
|
|
|
22
22
|
buildStartSessionInstruction(options, sessionKey, tokenInfo),
|
|
23
23
|
]);
|
|
24
24
|
const result = await options.adapter.sendTransaction(sessionKey, [
|
|
25
|
-
intentInstruction,
|
|
26
25
|
...buildCreateAssociatedTokenAccountInstructions(options, tokenInfo),
|
|
26
|
+
intentInstruction,
|
|
27
27
|
startSessionInstruction,
|
|
28
28
|
]);
|
|
29
29
|
switch (result.type) {
|
|
@@ -113,12 +113,14 @@ const buildMessage = async (body) => new TextEncoder().encode([
|
|
|
113
113
|
const serializeKV = (data) => Object.entries(data)
|
|
114
114
|
.map(([key, value]) => [key, ":", value.startsWith("\n") ? "" : " ", value].join(""))
|
|
115
115
|
.join("\n");
|
|
116
|
-
const serializeTokenList = (tokens) => tokens
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
const serializeTokenList = (tokens) => tokens.length === 0
|
|
117
|
+
? "\n"
|
|
118
|
+
: tokens
|
|
119
|
+
.values()
|
|
120
|
+
.filter(({ amount }) => amount > 0n)
|
|
121
|
+
.map(({ symbolOrMint, amount, decimals }) => `\n-${symbolOrMint.type === SymbolOrMintType.Symbol ? symbolOrMint.symbol : symbolOrMint.mint.toBase58()}: ${amountToString(amount, decimals)}`)
|
|
122
|
+
.toArray()
|
|
123
|
+
.join("");
|
|
122
124
|
const amountToString = (amount, decimals) => {
|
|
123
125
|
const asStr = amount.toString();
|
|
124
126
|
const whole = asStr.length > decimals ? asStr.slice(0, asStr.length - decimals) : "0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fogo/sessions-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A set of utilities for integrating with Fogo sessions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fogo",
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"@solana/web3.js": "^1.92.3",
|
|
48
48
|
"bs58": "^6.0.0",
|
|
49
49
|
"zod": "^3.25.62",
|
|
50
|
-
"@fogo/sessions-idls": "0.0.
|
|
50
|
+
"@fogo/sessions-idls": "0.0.2"
|
|
51
51
|
}
|
|
52
52
|
}
|