@drift-labs/sdk 2.94.0-beta.9 → 2.95.0-beta.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/VERSION +1 -1
- package/lib/idl/drift.json +1 -1
- package/package.json +1 -1
- package/src/idl/drift.json +1 -1
- package/tests/ci/idl.ts +43 -10
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.95.0-beta.0
|
package/lib/idl/drift.json
CHANGED
package/package.json
CHANGED
package/src/idl/drift.json
CHANGED
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
|
});
|