Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2591 from 0xProject/feat/asset-swapper/exchange-p…
Browse files Browse the repository at this point in the history
…roxy-support

asset-swapper: Exchange Proxy support
  • Loading branch information
dorothy-zbornak authored Jun 12, 2020
2 parents 81d4803 + 7590471 commit 4fced27
Show file tree
Hide file tree
Showing 38 changed files with 1,867 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-coordinator @0x/contracts-erc20-bridge-sampler @0x/contracts-zero-ex
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-coordinator @0x/contracts-erc20-bridge-sampler @0x/contracts-broker @0x/contracts-zero-ex
test-publish:
resource_class: medium+
docker:
Expand Down
9 changes: 9 additions & 0 deletions contracts/broker/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "1.1.5",
"changes": [
{
"note": "Fix broken tests.",
"pr": 2591
}
]
},
{
"timestamp": 1583220306,
"version": "1.1.4",
Expand Down
4 changes: 2 additions & 2 deletions contracts/broker/test/gods_unchained_validator_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ blockchainTests.resets('GodsUnchainedValidator unit tests', env => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto.plus(1), quality).awaitTransactionSuccessAsync();
const tx = validator.checkBrokerAsset(tokenId, propertyData).callAsync();
expect(tx).to.revertWith('PROTO_MISMATCH');
expect(tx).to.revertWith('GodsUnchainedValidator/PROTO_MISMATCH');
});
it("reverts if assetData quality doesn't match proeprtyData", async () => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto, quality.plus(1)).awaitTransactionSuccessAsync();
const tx = validator.checkBrokerAsset(tokenId, propertyData).callAsync();
expect(tx).to.revertWith('QUALITY_MISMATCH');
expect(tx).to.revertWith('GodsUnchainedValidator/QUALITY_MISMATCH');
});
});
});
28 changes: 28 additions & 0 deletions contracts/zero-ex/src/transformer_data_encoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ export function encodeFillQuoteTransformerData(data: FillQuoteTransformerData):
return fillQuoteTransformerDataEncoder.encode([data]);
}

/**
* ABI-decode a `FillQuoteTransformer.TransformData` type.
*/
export function decodeFillQuoteTransformerData(encoded: string): FillQuoteTransformerData {
return fillQuoteTransformerDataEncoder.decode(encoded).data;
}

/**
* ABI encoder for `WethTransformer.TransformData`
*/
Expand All @@ -95,6 +102,13 @@ export function encodeWethTransformerData(data: WethTransformerData): string {
return wethTransformerDataEncoder.encode([data]);
}

/**
* ABI-decode a `WethTransformer.TransformData` type.
*/
export function decodeWethTransformerData(encoded: string): WethTransformerData {
return wethTransformerDataEncoder.decode(encoded).data;
}

/**
* ABI encoder for `PayTakerTransformer.TransformData`
*/
Expand All @@ -121,6 +135,13 @@ export function encodePayTakerTransformerData(data: PayTakerTransformerData): st
return payTakerTransformerDataEncoder.encode([data]);
}

/**
* ABI-decode a `PayTakerTransformer.TransformData` type.
*/
export function decodePayTakerTransformerData(encoded: string): PayTakerTransformerData {
return payTakerTransformerDataEncoder.decode(encoded).data;
}

/**
* ABI encoder for `PayTakerTransformer.TransformData`
*/
Expand Down Expand Up @@ -157,3 +178,10 @@ export interface AffiliateFeeTransformerData {
export function encodeAffiliateFeeTransformerData(data: AffiliateFeeTransformerData): string {
return affiliateFeeTransformerDataEncoder.encode(data);
}

/**
* ABI-decode a `AffiliateFeeTransformer.TransformData` type.
*/
export function decodeAffiliateFeeTransformerData(encoded: string): AffiliateFeeTransformerData {
return affiliateFeeTransformerDataEncoder.decode(encoded).data;
}
9 changes: 9 additions & 0 deletions packages/abi-gen/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "5.3.0",
"changes": [
{
"note": "Allow identifiers with leading underscores in python wrappers",
"pr": 2591
}
]
},
{
"version": "5.2.2",
"changes": [
Expand Down
11 changes: 10 additions & 1 deletion packages/abi-gen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,16 @@ if (args.language === 'TypeScript') {
registerPartials();

function makeLanguageSpecificName(methodName: string): string {
return args.language === 'Python' ? changeCase.snake(methodName) : methodName;
if (args.language === 'Python') {
let snakeCased = changeCase.snake(methodName);
// Move leading underscores to the end.
const m = /^(_*).+?(_*)$/.exec(methodName);
if (m) {
snakeCased = `${snakeCased}${m[1] || m[2]}`;
}
return snakeCased;
}
return methodName;
}

if (_.isEmpty(abiFileNames)) {
Expand Down
13 changes: 9 additions & 4 deletions packages/abi-gen/src/python_handlebars_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,15 @@ export function registerPythonHelpers(): void {
}
return '';
});
Handlebars.registerHelper(
'toPythonClassname',
(sourceName: string) => new Handlebars.SafeString(changeCase.pascal(sourceName)),
);
Handlebars.registerHelper('toPythonClassname', (sourceName: string) => {
let pascalCased = changeCase.pascal(sourceName);
// Retain trailing underscores.
const m = /^.+?(_*)$/.exec(sourceName);
if (m) {
pascalCased = `${pascalCased}${m[1]}`;
}
return new Handlebars.SafeString(pascalCased);
});
Handlebars.registerHelper(
'makeOutputsValue',
/**
Expand Down
11 changes: 6 additions & 5 deletions packages/abi-gen/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,14 @@ export const utils = {
'max',
'round',
];
if (
pythonReservedWords.includes(snakeCased) ||
pythonBuiltins.includes(snakeCased) ||
/*changeCase strips leading underscores :(*/ input[0] === '_'
) {
if (pythonReservedWords.includes(snakeCased) || pythonBuiltins.includes(snakeCased)) {
snakeCased = `_${snakeCased}`;
}
// Retain trailing underscores.
const m = /^.+?(_*)$/.exec(input);
if (m) {
snakeCased = `${snakeCased}${m[1]}`;
}
return snakeCased;
},
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

class {{toPythonClassname this.languageSpecificName}}Method(ContractMethod):
class {{toPythonClassname this.languageSpecificName}}Method(ContractMethod): # pylint: disable=invalid-name
"""Various interfaces to the {{this.name}} method."""

def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function: ContractFunction{{#if inputs}}, validator: Validator=None{{/if}}):
Expand Down
Loading

0 comments on commit 4fced27

Please sign in to comment.