Skip to content

Commit

Permalink
Compatibility fix for new & old versions of truffle (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
CedarMist committed Jun 29, 2023
1 parent 9a74e57 commit 3bff308
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
- name: Test Integration Hardhat
run: pnpm test


test-client-go:
name: test-client-go
runs-on: ubuntu-latest
Expand All @@ -200,6 +200,18 @@ jobs:
strategy:
matrix:
example: [hardhat, hardhat-boilerplate, truffle]
truffle_version: [none, 5.8.2, 5.10.1]
exclude:
- example: hardhat
truffle_version: 5.8.2
- example: hardhat
truffle_version: 5.10.1
- example: hardhat-boilerplate
truffle_version: 5.8.2
- example: hardhat-boilerplate
truffle_version: 5.10.1
- example: truffle
truffle_version: none
defaults:
run:
working-directory: examples/${{ matrix.example }}
Expand Down Expand Up @@ -244,11 +256,16 @@ jobs:
with:
name: integration-hardhat
path: integrations/hardhat/dist

- name: Install dependencies
run: |
pnpm install
- name: Update Truffle version
if: ${{ matrix.example == 'truffle' && matrix.truffle_version != 'none' }}
run: |
pnpm up truffle@${{matrix.truffle_version}}
- name: Build
run: |
! grep -q '"build":' package.json || pnpm run build
Expand Down
14 changes: 12 additions & 2 deletions clients/js/src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,19 @@ export async function fetchRuntimePublicKey(
// first opportunistically try `send` from the provider
try {
const source = provider as {
send: (method: string, params: any[]) => Promise<any>;
send: (
method: string,
params: any[] | ((err: any, ok?: any) => void),
) => Promise<any>;
};
const { key } = await source.send(OASIS_CALL_DATA_PUBLIC_KEY, []);
const arg =
'engine' in provider
? // eslint-disable-next-line @typescript-eslint/no-unused-vars
function (err: any, ok?: any) {
return;
}
: [];
const { key } = await source.send(OASIS_CALL_DATA_PUBLIC_KEY, arg);
if (key) return arrayify(key);
} catch {
// don't do anything, move on to try chainId
Expand Down

0 comments on commit 3bff308

Please sign in to comment.