Skip to content

Commit a9c7683

Browse files
committed
fix(ink): incompatible error when dry-running on old chains
1 parent c78bb61 commit a9c7683

File tree

3 files changed

+57
-25
lines changed

3 files changed

+57
-25
lines changed

packages/sdk-ink/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
## 0.6.2 2025-12-13
6+
7+
### Fixed
8+
9+
- Fix incompatible error when dry-running on old chains.
10+
511
## 0.6.1 2025-12-13
612

713
### Fixed

packages/sdk-ink/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polkadot-api/sdk-ink",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"sideEffects": false,
55
"author": "Victor Oliva (https://github.com/voliva)",
66
"repository": {

packages/sdk-ink/src/provider.ts

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,18 @@ export const reviveProvider = (
238238
const typedApi = allApis.passet as CommonTypedApi | ReviveSdkTypedApi
239239

240240
const callOptions = atBest ? { at: "best" } : {}
241-
const traceCall = ({
241+
const traceCall = async ({
242242
from,
243243
to,
244244
input,
245245
value,
246-
}: Pick<GenericTransaction, "from" | "to" | "input" | "value">) =>
247-
typedApi.apis.ReviveApi.trace_call(
246+
}: Pick<GenericTransaction, "from" | "to" | "input" | "value">) => {
247+
const isPasset =
248+
await allApis.passet.apis.ReviveApi.trace_call.isCompatible(
249+
CompatibilityLevel.BackwardsCompatible,
250+
)
251+
const api = isPasset ? allApis.passet : allApis.pasAh
252+
return api.apis.ReviveApi.trace_call(
248253
{
249254
authorization_list: [],
250255
blob_versioned_hashes: [],
@@ -277,6 +282,7 @@ export const reviveProvider = (
277282
success: false as const,
278283
}
279284
})
285+
}
280286

281287
return {
282288
async getBalance(addr) {
@@ -294,15 +300,25 @@ export const reviveProvider = (
294300
input: Binary,
295301
) =>
296302
Promise.all([
297-
typedApi.apis.ReviveApi.call(
298-
origin,
299-
dest,
300-
value,
301-
gas_limit,
302-
storage_deposit_limit,
303-
input,
304-
callOptions,
305-
),
303+
allApis.passet.apis.ReviveApi.call
304+
.isCompatible(CompatibilityLevel.Partial)
305+
.then(
306+
(isPasset) =>
307+
(isPasset ? allApis.passet : allApis.pasAh) as
308+
| CommonTypedApi
309+
| ReviveSdkTypedApi,
310+
)
311+
.then(async (api) =>
312+
api.apis.ReviveApi.call(
313+
origin,
314+
dest,
315+
value,
316+
gas_limit,
317+
storage_deposit_limit,
318+
input,
319+
callOptions,
320+
),
321+
),
306322
traceCall({
307323
from: ss58ToEthereum(origin),
308324
input: {
@@ -352,16 +368,26 @@ export const reviveProvider = (
352368
salt: Binary | undefined,
353369
) =>
354370
Promise.all([
355-
typedApi.apis.ReviveApi.instantiate(
356-
origin,
357-
value,
358-
gas_limit,
359-
storage_deposit_limit,
360-
code,
361-
data,
362-
salt,
363-
callOptions,
364-
),
371+
allApis.passet.apis.ReviveApi.instantiate
372+
.isCompatible(CompatibilityLevel.Partial)
373+
.then(
374+
(isPasset) =>
375+
(isPasset ? allApis.passet : allApis.pasAh) as
376+
| CommonTypedApi
377+
| ReviveSdkTypedApi,
378+
)
379+
.then(async (api) =>
380+
api.apis.ReviveApi.instantiate(
381+
origin,
382+
value,
383+
gas_limit,
384+
storage_deposit_limit,
385+
code,
386+
data,
387+
salt,
388+
callOptions,
389+
),
390+
),
365391
typedApi.constants.Revive.NativeToEthRatio().then((nativeToEth) =>
366392
traceCall({
367393
from: ss58ToEthereum(origin),
@@ -492,7 +518,7 @@ export const reviveProvider = (
492518
}
493519

494520
return (
495-
typedApi as Exclude<
521+
allApis.pasAh as Exclude<
496522
CommonTypedApi | ReviveSdkTypedApi,
497523
TypedApi<Passet>
498524
>
@@ -555,7 +581,7 @@ export const reviveProvider = (
555581
}
556582

557583
return (
558-
typedApi as Exclude<
584+
allApis.pasAh as Exclude<
559585
CommonTypedApi | ReviveSdkTypedApi,
560586
TypedApi<Passet>
561587
>

0 commit comments

Comments
 (0)