@exponent-labs/exponent-types 0.0.3 → 0.0.4
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/build/cpi.d.ts +2 -0
- package/build/cpi.js +32 -0
- package/build/cpi.js.map +1 -1
- package/build/generic.d.ts +19 -1
- package/build/generic.js +28 -1
- package/build/generic.js.map +1 -1
- package/package.json +2 -3
- package/src/cpi.ts +31 -0
- package/src/generic.ts +47 -1
package/build/cpi.d.ts
CHANGED
|
@@ -35,3 +35,5 @@ export type AccountInfoJson = {
|
|
|
35
35
|
isSigner: boolean;
|
|
36
36
|
isWritable: boolean;
|
|
37
37
|
};
|
|
38
|
+
export declare function deserializeCpiAccountsRaw(serialized: CpiAccountsRawJson): CpiAccountsRaw;
|
|
39
|
+
export declare function serializeCpiAccountsRaw(cpiAccounts: CpiAccountsRaw): CpiAccountsRawJson;
|
package/build/cpi.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeCpiAccountsRaw = exports.deserializeCpiAccountsRaw = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
function deserializeCpiAccountsRaw(serialized) {
|
|
6
|
+
const deserializeAccountInfo = (accountInfo) => ({
|
|
7
|
+
pubkey: new anchor_1.web3.PublicKey(accountInfo.pubkey),
|
|
8
|
+
isSigner: accountInfo.isSigner,
|
|
9
|
+
isWritable: accountInfo.isWritable,
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
getSyState: serialized.getSyState.map(deserializeAccountInfo),
|
|
13
|
+
withdrawSy: serialized.withdrawSy.map(deserializeAccountInfo),
|
|
14
|
+
depositSy: serialized.depositSy.map(deserializeAccountInfo),
|
|
15
|
+
claimEmission: serialized.claimEmission.map((accounts) => accounts.map(deserializeAccountInfo)),
|
|
16
|
+
getPositionState: serialized.getPositionState.map(deserializeAccountInfo),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.deserializeCpiAccountsRaw = deserializeCpiAccountsRaw;
|
|
20
|
+
function serializeCpiAccountsRaw(cpiAccounts) {
|
|
21
|
+
const serializeAccountInfo = (accountInfo) => ({
|
|
22
|
+
pubkey: accountInfo.pubkey.toString(),
|
|
23
|
+
isSigner: accountInfo.isSigner,
|
|
24
|
+
isWritable: accountInfo.isWritable,
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
getSyState: cpiAccounts.getSyState.map(serializeAccountInfo),
|
|
28
|
+
withdrawSy: cpiAccounts.withdrawSy.map(serializeAccountInfo),
|
|
29
|
+
depositSy: cpiAccounts.depositSy.map(serializeAccountInfo),
|
|
30
|
+
claimEmission: cpiAccounts.claimEmission.map((accounts) => accounts.map(serializeAccountInfo)),
|
|
31
|
+
getPositionState: cpiAccounts.getPositionState.map(serializeAccountInfo),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.serializeCpiAccountsRaw = serializeCpiAccountsRaw;
|
|
3
35
|
//# sourceMappingURL=cpi.js.map
|
package/build/cpi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpi.js","sourceRoot":"","sources":["../src/cpi.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"cpi.js","sourceRoot":"","sources":["../src/cpi.ts"],"names":[],"mappings":";;;AAAA,8CAAwC;AA6CxC,SAAgB,yBAAyB,CAAC,UAA8B;IACtE,MAAM,sBAAsB,GAAG,CAAC,WAA4B,EAAe,EAAE,CAAC,CAAC;QAC7E,MAAM,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;QAC9C,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,UAAU,EAAE,WAAW,CAAC,UAAU;KACnC,CAAC,CAAA;IACF,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,CAA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
18
|
};
|
|
19
|
+
export type InterfaceTypeGenericJson = {
|
|
20
|
+
pyth: {
|
|
21
|
+
lastSlot: string;
|
|
22
|
+
maximumAgeSeconds: string;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
splStakePool: Record<string, never>;
|
|
26
|
+
} | {
|
|
27
|
+
one: Record<string, never>;
|
|
28
|
+
} | {
|
|
29
|
+
fragmetric: Record<string, never>;
|
|
30
|
+
} | {
|
|
31
|
+
meteora: Record<string, never>;
|
|
32
|
+
};
|
|
19
33
|
export interface Hook {
|
|
20
34
|
enabled: boolean;
|
|
21
35
|
interfaceEmissionsAccountsUntil: number;
|
|
@@ -51,7 +65,7 @@ export interface GenericSyMetaAccountJson {
|
|
|
51
65
|
yieldBearingMint: string;
|
|
52
66
|
tokenSyEscrow: string;
|
|
53
67
|
interfaceAccounts: string[];
|
|
54
|
-
interfaceType:
|
|
68
|
+
interfaceType: InterfaceTypeGenericJson;
|
|
55
69
|
maxSySupply: string;
|
|
56
70
|
minMintSize: string;
|
|
57
71
|
minRedeemSize: string;
|
|
@@ -87,3 +101,7 @@ export interface GenericSyMetaAccountRaw {
|
|
|
87
101
|
hook: HookRaw;
|
|
88
102
|
}
|
|
89
103
|
export declare function deserializeGenericSyMetaAccountRaw(raw: GenericSyMetaAccountRaw): GenericSyMetaAccount;
|
|
104
|
+
/** Convert InterfaceTypeGeneric to InterfaceTypeGenericJson */
|
|
105
|
+
export declare function toInterfaceTypeGenericJson(interfaceType: InterfaceTypeGeneric): InterfaceTypeGenericJson;
|
|
106
|
+
/** Convert InterfaceTypeGenericJson to InterfaceTypeGeneric */
|
|
107
|
+
export declare function fromInterfaceTypeGenericJson(json: InterfaceTypeGenericJson): InterfaceTypeGeneric;
|
package/build/generic.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeGenericSyMetaAccountRaw = void 0;
|
|
3
|
+
exports.fromInterfaceTypeGenericJson = exports.toInterfaceTypeGenericJson = exports.deserializeGenericSyMetaAccountRaw = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
4
5
|
function deserializeGenericSyMetaAccountRaw(raw) {
|
|
5
6
|
return {
|
|
6
7
|
mintSy: raw.mintSy,
|
|
@@ -23,4 +24,30 @@ function deserializeGenericSyMetaAccountRaw(raw) {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
exports.deserializeGenericSyMetaAccountRaw = deserializeGenericSyMetaAccountRaw;
|
|
27
|
+
/** Convert InterfaceTypeGeneric to InterfaceTypeGenericJson */
|
|
28
|
+
function toInterfaceTypeGenericJson(interfaceType) {
|
|
29
|
+
if ("pyth" in interfaceType) {
|
|
30
|
+
return {
|
|
31
|
+
pyth: {
|
|
32
|
+
lastSlot: interfaceType.pyth.lastSlot.toString(),
|
|
33
|
+
maximumAgeSeconds: interfaceType.pyth.maximumAgeSeconds.toString(),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return interfaceType;
|
|
38
|
+
}
|
|
39
|
+
exports.toInterfaceTypeGenericJson = toInterfaceTypeGenericJson;
|
|
40
|
+
/** Convert InterfaceTypeGenericJson to InterfaceTypeGeneric */
|
|
41
|
+
function fromInterfaceTypeGenericJson(json) {
|
|
42
|
+
if ("pyth" in json) {
|
|
43
|
+
return {
|
|
44
|
+
pyth: {
|
|
45
|
+
lastSlot: new anchor_1.BN(json.pyth.lastSlot),
|
|
46
|
+
maximumAgeSeconds: new anchor_1.BN(json.pyth.maximumAgeSeconds),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return json;
|
|
51
|
+
}
|
|
52
|
+
exports.fromInterfaceTypeGenericJson = fromInterfaceTypeGenericJson;
|
|
26
53
|
//# sourceMappingURL=generic.js.map
|
package/build/generic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAwH5C,SAAgB,kCAAkC,CAAC,GAA4B;IAC7E,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;QACtC,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO;YACzB,+BAA+B,EAAE,GAAG,CAAC,IAAI,CAAC,+BAA+B;YACzE,wBAAwB,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC;YACvE,2BAA2B,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,2BAA2B,CAAC;YAC7E,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS;SAC9B;KACF,CAAA;AACH,CAAC;AApBD,gFAoBC;AAED,+DAA+D;AAC/D,SAAgB,0BAA0B,CAAC,aAAmC;IAC5E,IAAI,MAAM,IAAI,aAAa,EAAE,CAAC;QAC5B,OAAO;YACL,IAAI,EAAE;gBACJ,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;gBAChD,iBAAiB,EAAE,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE;aACnE;SACF,CAAA;IACH,CAAC;IACD,OAAO,aAAyC,CAAA;AAClD,CAAC;AAVD,gEAUC;AAED,+DAA+D;AAC/D,SAAgB,4BAA4B,CAAC,IAA8B;IACzE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO;YACL,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI,WAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBACpC,iBAAiB,EAAE,IAAI,WAAE,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;aACvD;SACF,CAAA;IACH,CAAC;IACD,OAAO,IAA4B,CAAA;AACrC,CAAC;AAVD,oEAUC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exponent-labs/exponent-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"build": "tsc --build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@coral-xyz/anchor": "0.30.1"
|
|
12
|
-
"@exponent-labs/precise-number": "^0.0.3"
|
|
11
|
+
"@coral-xyz/anchor": "0.30.1"
|
|
13
12
|
},
|
|
14
13
|
"devDependencies": {
|
|
15
14
|
"typescript": "5.4.5"
|
package/src/cpi.ts
CHANGED
|
@@ -42,3 +42,34 @@ export type AccountInfoJson = {
|
|
|
42
42
|
isSigner: boolean
|
|
43
43
|
isWritable: boolean
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
export function deserializeCpiAccountsRaw(serialized: CpiAccountsRawJson): CpiAccountsRaw {
|
|
47
|
+
const deserializeAccountInfo = (accountInfo: AccountInfoJson): AccountInfo => ({
|
|
48
|
+
pubkey: new web3.PublicKey(accountInfo.pubkey),
|
|
49
|
+
isSigner: accountInfo.isSigner,
|
|
50
|
+
isWritable: accountInfo.isWritable,
|
|
51
|
+
})
|
|
52
|
+
return {
|
|
53
|
+
getSyState: serialized.getSyState.map(deserializeAccountInfo),
|
|
54
|
+
withdrawSy: serialized.withdrawSy.map(deserializeAccountInfo),
|
|
55
|
+
depositSy: serialized.depositSy.map(deserializeAccountInfo),
|
|
56
|
+
claimEmission: serialized.claimEmission.map((accounts) => accounts.map(deserializeAccountInfo)),
|
|
57
|
+
getPositionState: serialized.getPositionState.map(deserializeAccountInfo),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function serializeCpiAccountsRaw(cpiAccounts: CpiAccountsRaw): CpiAccountsRawJson {
|
|
62
|
+
const serializeAccountInfo = (accountInfo: AccountInfo) => ({
|
|
63
|
+
pubkey: accountInfo.pubkey.toString(),
|
|
64
|
+
isSigner: accountInfo.isSigner,
|
|
65
|
+
isWritable: accountInfo.isWritable,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
getSyState: cpiAccounts.getSyState.map(serializeAccountInfo),
|
|
70
|
+
withdrawSy: cpiAccounts.withdrawSy.map(serializeAccountInfo),
|
|
71
|
+
depositSy: cpiAccounts.depositSy.map(serializeAccountInfo),
|
|
72
|
+
claimEmission: cpiAccounts.claimEmission.map((accounts) => accounts.map(serializeAccountInfo)),
|
|
73
|
+
getPositionState: cpiAccounts.getPositionState.map(serializeAccountInfo),
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/generic.ts
CHANGED
|
@@ -21,6 +21,26 @@ export type InterfaceTypeGeneric =
|
|
|
21
21
|
meteora: Record<string, never>
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export type InterfaceTypeGenericJson =
|
|
25
|
+
| {
|
|
26
|
+
pyth: {
|
|
27
|
+
lastSlot: string
|
|
28
|
+
maximumAgeSeconds: string
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
splStakePool: Record<string, never>
|
|
33
|
+
}
|
|
34
|
+
| {
|
|
35
|
+
one: Record<string, never>
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
fragmetric: Record<string, never>
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
meteora: Record<string, never>
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
export interface Hook {
|
|
25
45
|
enabled: boolean
|
|
26
46
|
interfaceEmissionsAccountsUntil: number
|
|
@@ -60,7 +80,7 @@ export interface GenericSyMetaAccountJson {
|
|
|
60
80
|
yieldBearingMint: string
|
|
61
81
|
tokenSyEscrow: string
|
|
62
82
|
interfaceAccounts: string[]
|
|
63
|
-
interfaceType:
|
|
83
|
+
interfaceType: InterfaceTypeGenericJson
|
|
64
84
|
maxSySupply: string
|
|
65
85
|
minMintSize: string
|
|
66
86
|
minRedeemSize: string
|
|
@@ -119,3 +139,29 @@ export function deserializeGenericSyMetaAccountRaw(raw: GenericSyMetaAccountRaw)
|
|
|
119
139
|
},
|
|
120
140
|
}
|
|
121
141
|
}
|
|
142
|
+
|
|
143
|
+
/** Convert InterfaceTypeGeneric to InterfaceTypeGenericJson */
|
|
144
|
+
export function toInterfaceTypeGenericJson(interfaceType: InterfaceTypeGeneric): InterfaceTypeGenericJson {
|
|
145
|
+
if ("pyth" in interfaceType) {
|
|
146
|
+
return {
|
|
147
|
+
pyth: {
|
|
148
|
+
lastSlot: interfaceType.pyth.lastSlot.toString(),
|
|
149
|
+
maximumAgeSeconds: interfaceType.pyth.maximumAgeSeconds.toString(),
|
|
150
|
+
},
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return interfaceType as InterfaceTypeGenericJson
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Convert InterfaceTypeGenericJson to InterfaceTypeGeneric */
|
|
157
|
+
export function fromInterfaceTypeGenericJson(json: InterfaceTypeGenericJson): InterfaceTypeGeneric {
|
|
158
|
+
if ("pyth" in json) {
|
|
159
|
+
return {
|
|
160
|
+
pyth: {
|
|
161
|
+
lastSlot: new BN(json.pyth.lastSlot),
|
|
162
|
+
maximumAgeSeconds: new BN(json.pyth.maximumAgeSeconds),
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return json as InterfaceTypeGeneric
|
|
167
|
+
}
|