Skip to content

Commit

Permalink
Merge pull request #148 from drips-network/original-nft-minter
Browse files Browse the repository at this point in the history
Original nft minter
  • Loading branch information
efstajas authored Oct 24, 2023
2 parents 352155c + 1e212f1 commit d61df5f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/DripsSubgraph/DripsSubgraphClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ export default class DripsSubgraphClient {
return nftSubAccounts
? nftSubAccounts.map((s) => ({
tokenId: s.id,
ownerAddress: ethers.utils.getAddress(s.ownerAddress)
ownerAddress: ethers.utils.getAddress(s.ownerAddress),
originalOwnerAddress: ethers.utils.getAddress(s.originalOwnerAddress)
}))
: [];
}
Expand All @@ -473,7 +474,11 @@ export default class DripsSubgraphClient {
const nftSubAccount = response?.data?.nftsubAccount;

return nftSubAccount
? { tokenId: nftSubAccount.id, ownerAddress: ethers.utils.getAddress(nftSubAccount.ownerAddress) }
? {
tokenId: nftSubAccount.id,
ownerAddress: ethers.utils.getAddress(nftSubAccount.ownerAddress),
originalOwnerAddress: ethers.utils.getAddress(nftSubAccount.originalOwnerAddress)
}
: null;
}

Expand Down
2 changes: 2 additions & 0 deletions src/DripsSubgraph/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ query getNftSubAccountsByOwner($ownerAddress: Bytes!, $skip: Int, $first: Int) {
nftsubAccounts(where: {ownerAddress: $ownerAddress}, skip: $skip, first: $first) {
id
ownerAddress
originalOwnerAddress
}
}
`;
Expand All @@ -150,6 +151,7 @@ query getNftSubAccountOwnerByTokenId($tokenId: ID!) {
nftsubAccount(id: $tokenId) {
id
ownerAddress
originalOwnerAddress
}
}
`;
Expand Down
1 change: 1 addition & 0 deletions src/DripsSubgraph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export type AccountMetadataEntry = {
export type NftSubAccount = {
tokenId: string;
ownerAddress: string;
originalOwnerAddress: string;
};

export type StreamsSetEventWithFullReceivers = {
Expand Down
8 changes: 6 additions & 2 deletions tests/DripsSubgraph/DripsSubgraphClient.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,8 @@ describe('DripsSubgraphClient', () => {
const nftsubAccounts: SubgraphTypes.NftSubAccount[] = [
{
id: '1',
ownerAddress: Wallet.createRandom().address
ownerAddress: Wallet.createRandom().address,
originalOwnerAddress: Wallet.createRandom().address
}
];

Expand All @@ -976,6 +977,7 @@ describe('DripsSubgraphClient', () => {
// Assert
assert.equal(result![0].tokenId, nftsubAccounts[0].id);
assert.equal(result![0].ownerAddress, nftsubAccounts[0].ownerAddress);
assert.equal(result![0].originalOwnerAddress, nftsubAccounts[0].originalOwnerAddress);
assert(
clientStub.calledOnceWithExactly(gql.getNftSubAccountsByOwner, { ownerAddress, skip: 0, first: 100 }),
'Expected method to be called with different arguments'
Expand Down Expand Up @@ -1009,7 +1011,8 @@ describe('DripsSubgraphClient', () => {
const tokenId = '1';
const nftsubAccount: SubgraphTypes.NftSubAccount = {
id: tokenId,
ownerAddress: Wallet.createRandom().address
ownerAddress: Wallet.createRandom().address,
originalOwnerAddress: Wallet.createRandom().address
};

const clientStub = sinon
Expand All @@ -1027,6 +1030,7 @@ describe('DripsSubgraphClient', () => {
// Assert
assert.equal(result!.tokenId, nftsubAccount.id);
assert.equal(result!.ownerAddress, nftsubAccount.ownerAddress);
assert.equal(result!.originalOwnerAddress, nftsubAccount.originalOwnerAddress);
assert(
clientStub.calledOnceWithExactly(gql.getNftSubAccountOwnerByTokenId, { tokenId }),
'Expected method to be called with different arguments'
Expand Down

0 comments on commit d61df5f

Please sign in to comment.