-
Notifications
You must be signed in to change notification settings - Fork 259
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
12 changed files
with
242 additions
and
5 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,6 @@ | ||
--- | ||
'@moralisweb3/common-streams-utils': patch | ||
'@moralisweb3/streams': patch | ||
--- | ||
|
||
Added the `ntfTokenApprovals` property to the `EvmStreamResult` class. The `nftApprovals` property is depreciated now. |
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
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
42 changes: 42 additions & 0 deletions
42
...on/streamsUtils/src/dataTypes/StreamEvmNftTokenApproval/StreamEvmNftTokenApproval.test.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,42 @@ | ||
import Core from '@moralisweb3/common-core'; | ||
import { setupStreamsUtils } from '../../test/setup'; | ||
import { StreamEvmNftTokenApproval } from './StreamEvmNftTokenApproval'; | ||
|
||
describe('StreamEvmNftTokenApproval', () => { | ||
let core: Core; | ||
|
||
beforeAll(() => { | ||
core = setupStreamsUtils(); | ||
}); | ||
|
||
it('should return correct values for all getters', () => { | ||
const approval = StreamEvmNftTokenApproval.create( | ||
{ | ||
chain: '0x22', | ||
transactionHash: '0x8b7ed07563c2e679b9b49e2e0b62d1fe8a37c2f6c6d43a6ed072d1fc9ac15a22', | ||
logIndex: '361', | ||
contract: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', | ||
account: '0x0a1ad77312d36459179ad622c2a8a6280cc79419', | ||
operator: '0x0000000000000000000000000000000000000000', | ||
approvedAll: false, | ||
tokenId: '2947', | ||
tokenName: 'BoredApeYachtClub', | ||
tokenSymbol: 'BAYC', | ||
tokenContractType: 'ERC721', | ||
}, | ||
core, | ||
); | ||
|
||
expect(approval.chain.decimal).toBe(0x22); | ||
expect(approval.transactionHash).toBe('0x8b7ed07563c2e679b9b49e2e0b62d1fe8a37c2f6c6d43a6ed072d1fc9ac15a22'); | ||
expect(approval.logIndex).toBe('361'); | ||
expect(approval.contract).toBe('0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d'); | ||
expect(approval.account).toBe('0x0a1ad77312d36459179ad622c2a8a6280cc79419'); | ||
expect(approval.operator).toBe('0x0000000000000000000000000000000000000000'); | ||
expect(approval.approvedAll).toBe(false); | ||
expect(approval.tokenId).toBe('2947'); | ||
expect(approval.tokenName).toBe('BoredApeYachtClub'); | ||
expect(approval.tokenSymbol).toBe('BAYC'); | ||
expect(approval.tokenContractType).toBe('ERC721'); | ||
}); | ||
}); |
105 changes: 105 additions & 0 deletions
105
.../common/streamsUtils/src/dataTypes/StreamEvmNftTokenApproval/StreamEvmNftTokenApproval.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,105 @@ | ||
import { | ||
Core, | ||
CoreProvider, | ||
MoralisDataFormatted, | ||
MoralisDataObject, | ||
MoralisDataObjectValue, | ||
} from '@moralisweb3/common-core'; | ||
import { StreamEvmNftTokenApprovalData, StreamEvmNftTokenApprovalish } from './types'; | ||
import { EvmChain } from '@moralisweb3/common-evm-utils'; | ||
|
||
/** | ||
* The `StreamEvmNftTokenApproval` class is a representation of the NFT approval data. | ||
* | ||
* @category DataType | ||
*/ | ||
export class StreamEvmNftTokenApproval implements StreamEvmNftTokenApprovalData, MoralisDataObject { | ||
public static create(data: StreamEvmNftTokenApprovalish, core?: Core): StreamEvmNftTokenApproval { | ||
const finalCore = core ?? CoreProvider.getDefault(); | ||
const chain = EvmChain.create(data.chain, finalCore); | ||
return new StreamEvmNftTokenApproval({ | ||
...data, | ||
chain, | ||
}); | ||
} | ||
|
||
private constructor(private readonly data: StreamEvmNftTokenApprovalData) {} | ||
|
||
public get chain(): EvmChain { | ||
return this.data.chain; | ||
} | ||
|
||
public get contract(): string { | ||
return this.data.contract; | ||
} | ||
|
||
public get account(): string { | ||
return this.data.account; | ||
} | ||
|
||
public get operator(): string { | ||
return this.data.operator; | ||
} | ||
public get approvedAll(): boolean { | ||
return this.data.approvedAll; | ||
} | ||
|
||
public get tokenId(): string | null { | ||
return this.data.tokenId; | ||
} | ||
|
||
public get transactionHash(): string { | ||
return this.data.transactionHash; | ||
} | ||
|
||
public get logIndex(): string { | ||
return this.data.logIndex; | ||
} | ||
|
||
public get tokenContractType(): string { | ||
return this.data.tokenContractType; | ||
} | ||
|
||
public get tokenName(): string { | ||
return this.data.tokenName; | ||
} | ||
|
||
public get tokenSymbol(): string { | ||
return this.data.tokenSymbol; | ||
} | ||
|
||
public toJSON(): MoralisDataObjectValue { | ||
return { | ||
chain: this.chain.format(), | ||
contract: this.contract, | ||
account: this.account, | ||
operator: this.operator, | ||
approvedAll: this.approvedAll, | ||
tokenId: this.tokenId, | ||
transactionHash: this.transactionHash, | ||
logIndex: this.logIndex, | ||
tokenContractType: this.tokenContractType, | ||
tokenName: this.tokenName, | ||
tokenSymbol: this.tokenSymbol, | ||
}; | ||
} | ||
|
||
public format(): MoralisDataFormatted { | ||
return this.toJSON(); | ||
} | ||
|
||
public equals(value: this): boolean { | ||
return ( | ||
this.contract === value.contract && | ||
this.account === value.account && | ||
this.operator === value.operator && | ||
this.approvedAll === value.approvedAll && | ||
this.tokenId === value.tokenId && | ||
this.transactionHash === value.transactionHash && | ||
this.logIndex === value.logIndex && | ||
this.tokenContractType === value.tokenContractType && | ||
this.tokenName === value.tokenName && | ||
this.tokenSymbol === value.tokenSymbol | ||
); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/common/streamsUtils/src/dataTypes/StreamEvmNftTokenApproval/index.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,2 @@ | ||
export * from './types'; | ||
export * from './StreamEvmNftTokenApproval'; |
10 changes: 10 additions & 0 deletions
10
packages/common/streamsUtils/src/dataTypes/StreamEvmNftTokenApproval/types.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,10 @@ | ||
import { EvmChain, EvmChainish } from '@moralisweb3/common-evm-utils'; | ||
import { INFTApproval } from '@moralisweb3/streams-typings'; | ||
|
||
export type StreamEvmNftTokenApprovalish = INFTApproval & { | ||
chain: EvmChainish; | ||
}; | ||
|
||
export type StreamEvmNftTokenApprovalData = INFTApproval & { | ||
chain: EvmChain; | ||
}; |
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
700a64f
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