-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
977 additions
and
294 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': patch | ||
'@moralisweb3/evm-api': patch | ||
'moralis': patch | ||
--- | ||
|
||
Add getWalletApprovals to SDK |
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
65 changes: 65 additions & 0 deletions
65
packages/common/evmUtils/src/generated/operations/GetWalletApprovalsOperation.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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { EvmChain, EvmChainInput, EvmChainJSON, EvmAddress, EvmAddressInput, EvmAddressJSON } from '../../dataTypes'; | ||
import { EvmWalletApprovals, EvmWalletApprovalsJSON } from '../types/EvmWalletApprovals'; | ||
|
||
// request parameters: | ||
// - chain ($ref: #/components/schemas/chainList) | ||
// - limit ($ref: #/paths/~1wallets~1{address}~1approvals/get/parameters/1/schema) | ||
// - cursor ($ref: #/paths/~1wallets~1{address}~1approvals/get/parameters/2/schema) | ||
// - address ($ref: #/paths/~1wallets~1{address}~1approvals/get/parameters/3/schema) | ||
|
||
export interface GetWalletApprovalsOperationRequest { | ||
/** | ||
* @description The chain to query | ||
*/ | ||
readonly chain?: EvmChainInput | EvmChain; | ||
/** | ||
* @description The desired page size of the result. | ||
*/ | ||
readonly limit?: number; | ||
/** | ||
* @description The cursor returned in the previous response (used for getting the next page). | ||
*/ | ||
readonly cursor?: string; | ||
/** | ||
* @description The wallet address from which to retrieve active ERC20 token approvals | ||
*/ | ||
readonly address: EvmAddressInput | EvmAddress; | ||
} | ||
|
||
export interface GetWalletApprovalsOperationRequestJSON { | ||
readonly chain?: EvmChainJSON; | ||
readonly limit?: number; | ||
readonly cursor?: string; | ||
readonly address: EvmAddressJSON; | ||
} | ||
|
||
export type GetWalletApprovalsOperationResponse = EvmWalletApprovals; | ||
export type GetWalletApprovalsOperationResponseJSON = EvmWalletApprovalsJSON; | ||
|
||
export const GetWalletApprovalsOperation = { | ||
operationId: "getWalletApprovals", | ||
groupName: "wallets", | ||
httpMethod: "get", | ||
routePattern: "/wallets/{address}/approvals", | ||
parameterNames: ["chain","limit","cursor","address"], | ||
hasResponse: true, | ||
hasBody: false, | ||
|
||
parseResponse(json: EvmWalletApprovalsJSON): EvmWalletApprovals { | ||
return EvmWalletApprovals.fromJSON(json); | ||
}, | ||
|
||
serializeRequest(request: GetWalletApprovalsOperationRequest): GetWalletApprovalsOperationRequestJSON { | ||
const chain = request.chain ? EvmChain.create(request.chain) : undefined; | ||
const limit = request.limit; | ||
const cursor = request.cursor; | ||
const address = EvmAddress.create(request.address); | ||
return { | ||
chain: chain ? chain.toJSON() : undefined, | ||
limit: limit, | ||
cursor: cursor, | ||
address: address.toJSON(), | ||
}; | ||
}, | ||
|
||
} |
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
64 changes: 64 additions & 0 deletions
64
packages/common/evmUtils/src/generated/types/EvmApprovalData.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { EvmTokenDetails, EvmTokenDetailsInput, EvmTokenDetailsJSON } from '../types/EvmTokenDetails'; | ||
import { EvmSpenderDetails, EvmSpenderDetailsInput, EvmSpenderDetailsJSON } from '../types/EvmSpenderDetails'; | ||
|
||
// $ref: #/components/schemas/ApprovalData | ||
// type: ApprovalData | ||
// properties: | ||
// - value ($ref: #/components/schemas/ApprovalData/properties/value) | ||
// - value_formatted ($ref: #/components/schemas/ApprovalData/properties/value_formatted) | ||
// - token ($ref: #/components/schemas/TokenDetails) | ||
// - spender ($ref: #/components/schemas/SpenderDetails) | ||
|
||
export interface EvmApprovalDataJSON { | ||
readonly value?: string; | ||
readonly value_formatted?: string; | ||
readonly token?: EvmTokenDetailsJSON; | ||
readonly spender?: EvmSpenderDetailsJSON; | ||
} | ||
|
||
export interface EvmApprovalDataInput { | ||
readonly value?: string; | ||
readonly valueFormatted?: string; | ||
readonly token?: EvmTokenDetailsInput | EvmTokenDetails; | ||
readonly spender?: EvmSpenderDetailsInput | EvmSpenderDetails; | ||
} | ||
|
||
export class EvmApprovalData { | ||
public static create(input: EvmApprovalDataInput | EvmApprovalData): EvmApprovalData { | ||
if (input instanceof EvmApprovalData) { | ||
return input; | ||
} | ||
return new EvmApprovalData(input); | ||
} | ||
|
||
public static fromJSON(json: EvmApprovalDataJSON): EvmApprovalData { | ||
const input: EvmApprovalDataInput = { | ||
value: json.value, | ||
valueFormatted: json.value_formatted, | ||
token: json.token ? EvmTokenDetails.fromJSON(json.token) : undefined, | ||
spender: json.spender ? EvmSpenderDetails.fromJSON(json.spender) : undefined, | ||
}; | ||
return EvmApprovalData.create(input); | ||
} | ||
|
||
public readonly value?: string; | ||
public readonly valueFormatted?: string; | ||
public readonly token?: EvmTokenDetails; | ||
public readonly spender?: EvmSpenderDetails; | ||
|
||
private constructor(input: EvmApprovalDataInput) { | ||
this.value = input.value; | ||
this.valueFormatted = input.valueFormatted; | ||
this.token = input.token ? EvmTokenDetails.create(input.token) : undefined; | ||
this.spender = input.spender ? EvmSpenderDetails.create(input.spender) : undefined; | ||
} | ||
|
||
public toJSON(): EvmApprovalDataJSON { | ||
return { | ||
value: this.value, | ||
value_formatted: this.valueFormatted, | ||
token: this.token ? this.token.toJSON() : undefined, | ||
spender: this.spender ? this.spender.toJSON() : undefined, | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
packages/common/evmUtils/src/generated/types/EvmApprovalResponse.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { EvmApprovalData, EvmApprovalDataInput, EvmApprovalDataJSON } from '../types/EvmApprovalData'; | ||
|
||
// $ref: #/components/schemas/ApprovalResponse | ||
// type: ApprovalResponse | ||
// properties: | ||
// - approvals ($ref: #/components/schemas/ApprovalData) | ||
|
||
export interface EvmApprovalResponseJSON { | ||
readonly approvals?: EvmApprovalDataJSON[]; | ||
} | ||
|
||
export interface EvmApprovalResponseInput { | ||
readonly approvals?: EvmApprovalDataInput[] | EvmApprovalData[]; | ||
} | ||
|
||
export class EvmApprovalResponse { | ||
public static create(input: EvmApprovalResponseInput | EvmApprovalResponse): EvmApprovalResponse { | ||
if (input instanceof EvmApprovalResponse) { | ||
return input; | ||
} | ||
return new EvmApprovalResponse(input); | ||
} | ||
|
||
public static fromJSON(json: EvmApprovalResponseJSON): EvmApprovalResponse { | ||
const input: EvmApprovalResponseInput = { | ||
approvals: json.approvals ? json.approvals.map((item) => EvmApprovalData.fromJSON(item)) : undefined, | ||
}; | ||
return EvmApprovalResponse.create(input); | ||
} | ||
|
||
public static isInput(input: any): input is EvmApprovalResponseInput { | ||
return [].every((name) => input[name] !== undefined); | ||
} | ||
|
||
public static isJSON(json: any): json is EvmApprovalResponseJSON { | ||
return [].every((name) => json[name] !== undefined); | ||
} | ||
|
||
public readonly approvals?: EvmApprovalData[]; | ||
|
||
private constructor(input: EvmApprovalResponseInput) { | ||
this.approvals = input.approvals ? input.approvals.map((item) => EvmApprovalData.create(item)) : undefined; | ||
} | ||
|
||
public toJSON(): EvmApprovalResponseJSON { | ||
return { | ||
approvals: this.approvals ? this.approvals.map((item) => item.toJSON()) : undefined, | ||
} | ||
} | ||
} |
64 changes: 0 additions & 64 deletions
64
packages/common/evmUtils/src/generated/types/EvmCommonContractData.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
71d2b43
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