@drift-labs/sdk 2.94.0-beta.9 → 2.95.0-beta.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/VERSION +1 -1
- package/lib/idl/drift.json +1 -1
- package/lib/types.d.ts +3 -0
- package/lib/types.js +3 -0
- package/package.json +1 -1
- package/src/idl/drift.json +1 -1
- package/src/types.ts +3 -0
- package/tests/ci/idl.ts +43 -10
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.95.0-beta.1
|
package/lib/idl/drift.json
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -286,6 +286,9 @@ export declare class OrderActionExplanation {
|
|
|
286
286
|
static readonly ORDER_FILLED_WITH_SERUM: {
|
|
287
287
|
orderFillWithSerum: {};
|
|
288
288
|
};
|
|
289
|
+
static readonly ORDER_FILLED_WITH_OPENBOOK_V2: {
|
|
290
|
+
orderFilledWithOpenbookV2: {};
|
|
291
|
+
};
|
|
289
292
|
static readonly ORDER_FILLED_WITH_PHOENIX: {
|
|
290
293
|
orderFillWithPhoenix: {};
|
|
291
294
|
};
|
package/lib/types.js
CHANGED
|
@@ -188,6 +188,9 @@ OrderActionExplanation.RISK_INCREASING_ORDER = {
|
|
|
188
188
|
OrderActionExplanation.ORDER_FILLED_WITH_SERUM = {
|
|
189
189
|
orderFillWithSerum: {},
|
|
190
190
|
};
|
|
191
|
+
OrderActionExplanation.ORDER_FILLED_WITH_OPENBOOK_V2 = {
|
|
192
|
+
orderFilledWithOpenbookV2: {},
|
|
193
|
+
};
|
|
191
194
|
OrderActionExplanation.ORDER_FILLED_WITH_PHOENIX = {
|
|
192
195
|
orderFillWithPhoenix: {},
|
|
193
196
|
};
|
package/package.json
CHANGED
package/src/idl/drift.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -192,6 +192,9 @@ export class OrderActionExplanation {
|
|
|
192
192
|
static readonly ORDER_FILLED_WITH_SERUM = {
|
|
193
193
|
orderFillWithSerum: {},
|
|
194
194
|
};
|
|
195
|
+
static readonly ORDER_FILLED_WITH_OPENBOOK_V2 = {
|
|
196
|
+
orderFilledWithOpenbookV2: {},
|
|
197
|
+
};
|
|
195
198
|
static readonly ORDER_FILLED_WITH_PHOENIX = {
|
|
196
199
|
orderFillWithPhoenix: {},
|
|
197
200
|
};
|
package/tests/ci/idl.ts
CHANGED
|
@@ -3,10 +3,18 @@ import { Connection, Keypair } from '@solana/web3.js';
|
|
|
3
3
|
import { Wallet, Program } from '@coral-xyz/anchor';
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
5
|
import { assert } from 'chai';
|
|
6
|
-
import
|
|
6
|
+
import sdkIdl from '../../src/idl/drift.json';
|
|
7
7
|
|
|
8
8
|
dotenv.config();
|
|
9
9
|
|
|
10
|
+
const IDL_KEYS_TO_CHECK = [
|
|
11
|
+
'instructions',
|
|
12
|
+
'accounts',
|
|
13
|
+
'types',
|
|
14
|
+
'events',
|
|
15
|
+
'errors',
|
|
16
|
+
];
|
|
17
|
+
|
|
10
18
|
describe('Verify IDL', function () {
|
|
11
19
|
this.timeout(100_000);
|
|
12
20
|
const MAINNET_RPC_ENDPOINT = process.env.MAINNET_RPC_ENDPOINT;
|
|
@@ -37,23 +45,48 @@ describe('Verify IDL', function () {
|
|
|
37
45
|
});
|
|
38
46
|
|
|
39
47
|
it('verify idl', async () => {
|
|
40
|
-
const
|
|
48
|
+
const onChainIdl = await Program.fetchIdl(
|
|
41
49
|
mainnetDriftClient.program.programId,
|
|
42
50
|
mainnetDriftClient.provider
|
|
43
51
|
);
|
|
44
52
|
|
|
53
|
+
if (onChainIdl === null) {
|
|
54
|
+
throw new Error(`onChainIdl for ${mainnetDriftClient.program.programId.toBase58()} null`);
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
// anchor idl init seems to strip the metadata
|
|
46
|
-
|
|
58
|
+
onChainIdl['metadata'] = {
|
|
47
59
|
address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH',
|
|
48
60
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
driftIDL['version'] = null;
|
|
52
|
-
|
|
53
|
-
const encodedMainnetIdl = JSON.stringify(idl);
|
|
61
|
+
onChainIdl['version'] = '';
|
|
62
|
+
sdkIdl['version'] = '';
|
|
54
63
|
|
|
55
|
-
const
|
|
64
|
+
const encodedMainnetIdl = JSON.stringify(onChainIdl);
|
|
65
|
+
const encodedSdkIdl = JSON.stringify(sdkIdl);
|
|
56
66
|
|
|
57
|
-
|
|
67
|
+
try {
|
|
68
|
+
assert(encodedSdkIdl === encodedMainnetIdl, 'on-chain IDL does not match SDK IDL');
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const diff = {};
|
|
71
|
+
for (const key of IDL_KEYS_TO_CHECK) {
|
|
72
|
+
const onChainItems = onChainIdl[key];
|
|
73
|
+
const sdkItems = sdkIdl[key];
|
|
74
|
+
for (let i = 0; i < Math.max(onChainItems.length, sdkItems.length); i++) {
|
|
75
|
+
let onChainItem = null;
|
|
76
|
+
let sdkItem = null;
|
|
77
|
+
if (i < onChainItems.length) {
|
|
78
|
+
onChainItem = onChainItems[i];
|
|
79
|
+
}
|
|
80
|
+
if (i < sdkItems.length) {
|
|
81
|
+
sdkItem = sdkItems[i];
|
|
82
|
+
}
|
|
83
|
+
if (JSON.stringify(onChainItem) !== JSON.stringify(sdkItem)) {
|
|
84
|
+
diff[`${key}[${i}]`] = { onChainIdl: onChainItem, sdkIdl: sdkItem };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
console.error('IDL Difference:', JSON.stringify(diff, null, 2));
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
58
91
|
});
|
|
59
92
|
});
|