Skip to content

Commit

Permalink
Merge pull request #191 from oasisprotocol/xz/remove-truffle
Browse files Browse the repository at this point in the history
Remove Truffle support from TS client
  • Loading branch information
aefhm authored Oct 20, 2023
2 parents 9e791c4 + cb2cead commit d1932bc
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 3,185 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ jobs:
strategy:
matrix:
example: [hardhat, hardhat-boilerplate, onchain-signer]
include:
- example: truffle
- example: truffle
truffle_version: 5.8.2
- example: truffle
truffle_version: 5.10.1
defaults:
run:
working-directory: examples/${{ matrix.example }}
Expand Down Expand Up @@ -256,11 +250,6 @@ jobs:
run: |
pnpm install
- name: Update Truffle version
if: ${{ matrix.example == 'truffle' && matrix.truffle_version }}
run: |
pnpm up truffle@${{matrix.truffle_version}}
- name: Build
run: |
! grep -q '"build":' package.json || pnpm run build
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/contracts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ jobs:
working-directory: contracts
run: |
forge doc --build
- name: hardhat test examples/truffle
working-directory: examples/truffle
run: pnpm run test --network sapphire_localnet
env:
PRIVATE_KEY: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
- name: hardhat test examples/hardhat
working-directory: examples/hardhat
run: pnpm hardhat run --network sapphire_localnet scripts/run-vigil.ts
Expand Down
44 changes: 5 additions & 39 deletions clients/js/src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,6 @@ function envelopeFormatOk(

class EnvelopeError extends Error {}

function defer<T>() {
const deferred: {
promise?: Promise<T>;
resolve?: (value: T | PromiseLike<T>) => void;
reject?: (reason?: any) => void;
} = {};
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
return deferred;
}

/**
* Picks the most user-trusted runtime calldata public key source based on what
* connections are available.
Expand All @@ -658,38 +645,17 @@ export async function fetchRuntimePublicKey(
) => Promise<any> | void;
};

// For Truffle, turn a callback into an synchronous call
const deferred = defer<any>();
const truffle_callback = function (err: any, ok?: any) {
if (ok) {
deferred.resolve!(ok.result);
}
deferred.reject!(err);
return;
};

let resp;
if (
!isEthersSigner &&
!isEthers5Provider(provider) &&
!isEthers6Provider(provider)
) {
// Truffle HDWallet-Provider and EIP-1193 accept {method:,params:} dict
resp = await source.send(
{ method: OASIS_CALL_DATA_PUBLIC_KEY, params: [] },
truffle_callback,
);
if (resp === undefined) {
// Truffle HDWallet-provider uses a callback instead of returning a promise
resp = await deferred.promise;
if (resp === undefined) {
throw Error(
'Got unexpected `undefined` from source.send callback!',
);
}
} else {
// Otherwise, EIP-1193 compatible provider will have returned `result` key from promise
}
// EIP-1193 accepts {method:,params:} dict
resp = await source.send({
method: OASIS_CALL_DATA_PUBLIC_KEY,
params: [],
});
} else {
// Whereas Ethers accepts (method,params)
resp = await source.send(OASIS_CALL_DATA_PUBLIC_KEY, []);
Expand Down
7 changes: 0 additions & 7 deletions clients/js/type-only-test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as sapphire from '../src/index';
import Web3 from 'web3';
import { ethers as ethers5 } from 'ethers5';
import { ethers as ethers6 } from 'ethers6';
import HDWalletProvider from '@truffle/hdwallet-provider';

declare global {
interface Window {
Expand Down Expand Up @@ -70,9 +69,3 @@ test('EIP-1193', () => {
const provider = sapphire.wrap(window.ethereum);
}
});

test('truffle', () => {
const provider = sapphire.wrap(
new HDWalletProvider([''], 'https://testnet.sapphire.oasis.dev'),
);
});
1 change: 0 additions & 1 deletion clients/js/type-only-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"test": "tsc"
},
"dependencies": {
"@truffle/hdwallet-provider": "^2.0.14",
"@types/web3": "=1.0.20",
"@types/web3-provider-engine": "^14.0.1",
"ethereum-protocol": "^1.0.1",
Expand Down
1 change: 0 additions & 1 deletion examples/truffle/.gitattributes

This file was deleted.

2 changes: 0 additions & 2 deletions examples/truffle/.gitignore

This file was deleted.

22 changes: 0 additions & 22 deletions examples/truffle/LICENSE

This file was deleted.

3 changes: 0 additions & 3 deletions examples/truffle/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions examples/truffle/contracts/ConvertLib.sol

This file was deleted.

35 changes: 0 additions & 35 deletions examples/truffle/contracts/MetaCoin.sol

This file was deleted.

8 changes: 0 additions & 8 deletions examples/truffle/migrations/1_deploy_contracts.js

This file was deleted.

19 changes: 0 additions & 19 deletions examples/truffle/package.json

This file was deleted.

44 changes: 0 additions & 44 deletions examples/truffle/scripts/exercise.contract.js

This file was deleted.

27 changes: 0 additions & 27 deletions examples/truffle/test/TestMetaCoin.sol

This file was deleted.

42 changes: 0 additions & 42 deletions examples/truffle/test/metacoin.js

This file was deleted.

Loading

0 comments on commit d1932bc

Please sign in to comment.