-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: getWalletTokenBalancesPrice, getPairPrice, resolveAddressToDoma… (
#1179) feat: getWalletTokenBalancesPrice, getPairPrice, resolveAddressToDomain, resolveENSAddress, getWalletNetWorth.
- Loading branch information
Showing
25 changed files
with
1,234 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@moralisweb3/common-evm-utils': minor | ||
'@moralisweb3/evm-api': minor | ||
'moralis': minor | ||
--- | ||
|
||
Updated the types of the `toBlock` and `toDate` properties in the `GetNFTTradesOperationRequest` interface to number and Date, respectively. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@moralisweb3/common-evm-utils': patch | ||
'@moralisweb3/evm-api': patch | ||
'moralis': patch | ||
--- | ||
|
||
Added `getWalletTokenBalancesPrice`, `getPairPrice`, `resolveAddressToDomain`, `resolveENSAddress`, `getWalletNetWorth` methods to the EVM API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 18 additions & 5 deletions
23
...s/apiGenerator/src/generator/fileGenerators/codeGenerators/TypeConversionCodeGenerator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,47 @@ | ||
export class TypeConversionCodeGenerator { | ||
public static generate(sourceNativeType: string, targetNativeType: string, valueCode: string): string { | ||
public static generate( | ||
isRequired: boolean, | ||
sourceNativeType: string, | ||
targetNativeType: string, | ||
valueCode: string, | ||
): string { | ||
if (sourceNativeType === targetNativeType) { | ||
return valueCode; | ||
} | ||
|
||
let code: string | undefined; | ||
switch (targetNativeType) { | ||
case 'number': | ||
switch (sourceNativeType) { | ||
case 'string': | ||
return `Number(${valueCode})`; | ||
code = `Number(${valueCode})`; | ||
break; | ||
} | ||
break; | ||
|
||
case 'string': | ||
switch (sourceNativeType) { | ||
case 'number': | ||
return `String(${valueCode})`; | ||
code = `String(${valueCode})`; | ||
break; | ||
case 'Date': | ||
return `${valueCode}.toISOString()`; | ||
code = `${valueCode}.toISOString()`; | ||
break; | ||
} | ||
break; | ||
|
||
case 'Date': | ||
switch (sourceNativeType) { | ||
case 'string': | ||
return `new Date(${valueCode})`; | ||
code = `new Date(${valueCode})`; | ||
break; | ||
} | ||
break; | ||
} | ||
|
||
if (code) { | ||
return isRequired ? code : `${valueCode} !== undefined ? ${code} : undefined`; | ||
} | ||
throw new Error(`Conversion from ${sourceNativeType} to ${targetNativeType} is not supported`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
31d73a7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage