forked from trustwallet/trust-ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trustwallet#255 - add models: ERC721Transaction, ERC721TransactionOpe…
…ration, ERC721Token
- Loading branch information
1 parent
3934a41
commit 4279e84
Showing
8 changed files
with
219 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const mongoose = require("mongoose"); | ||
const mongoosePaginate = require("mongoose-paginate"); | ||
const Schema = mongoose.Schema; | ||
|
||
const erc721tokenSchema = new Schema({ | ||
_id: { | ||
type: String, | ||
required: true, | ||
}, | ||
tokens: [{ | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "ERC721Contract", | ||
required: true, | ||
index: true | ||
}] | ||
}, { | ||
versionKey: false, | ||
}); | ||
|
||
erc721tokenSchema.plugin(mongoosePaginate); | ||
|
||
export const ERC721Token = mongoose.model("ERC721Token", erc721tokenSchema ); |
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,92 @@ | ||
const mongoose = require("mongoose"); | ||
const mongoosePaginate = require("mongoose-paginate"); | ||
const Schema = mongoose.Schema; | ||
|
||
|
||
/** | ||
* Model for a single transaction. | ||
* | ||
* @type {"mongoose".Schema} | ||
*/ | ||
const transactionSchema = new Schema({ | ||
_id: { | ||
type: String, | ||
required: true | ||
}, | ||
blockNumber: { | ||
type: Number, | ||
required: true, | ||
index: true | ||
}, | ||
timeStamp: { | ||
type: String, | ||
required: true, | ||
index: true | ||
}, | ||
nonce: { | ||
type: Number, | ||
required: true | ||
}, | ||
from: { | ||
type: String, | ||
required: true | ||
}, | ||
to: { | ||
type: String, | ||
required: true | ||
}, | ||
addresses: [{ | ||
type: String, | ||
index: true | ||
}], | ||
value: { | ||
type: String, | ||
required: true | ||
}, | ||
gas: { | ||
type: String, | ||
required: true | ||
}, | ||
gasPrice: { | ||
type: String, | ||
required: true | ||
}, | ||
input: { | ||
type: String, | ||
required: true | ||
}, | ||
gasUsed: { | ||
type: String, | ||
required: true | ||
}, | ||
error: { | ||
type: String | ||
}, | ||
operations: [{ | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "ERC721TransactionOperation" | ||
}], | ||
contract: { | ||
type: String, | ||
default: null | ||
} | ||
|
||
}, { | ||
versionKey: false, | ||
toObject: { | ||
virtuals: true | ||
}, | ||
toJSON: { | ||
virtuals: true | ||
} | ||
}); | ||
|
||
transactionSchema.virtual("success").get(function() { | ||
if (this.hasOwnProperty("error")) { | ||
return this.error === ""; | ||
} | ||
}); | ||
|
||
transactionSchema.plugin(mongoosePaginate); | ||
|
||
export const ERC721Transaction = mongoose.model("Erc721Transaction", transactionSchema ); |
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 @@ | ||
const mongoose = require("mongoose"); | ||
const Schema = mongoose.Schema; | ||
|
||
/** | ||
* Model for a transaction action | ||
* specifying the purpose of a | ||
* transaction. | ||
* | ||
* @type {"mongoose".Schema} | ||
*/ | ||
const transactionOperationSchema = new Schema({ | ||
transactionId: { | ||
type: String, | ||
required: true, | ||
index: true | ||
}, | ||
type: { | ||
type: String, | ||
required: true | ||
}, | ||
from: { | ||
type: String, | ||
required: true | ||
}, | ||
to: { | ||
type: String, | ||
required: true | ||
}, | ||
value: { | ||
type: String, | ||
required: true | ||
}, | ||
contract: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "ERC721Contract", | ||
required: true | ||
} | ||
}, { | ||
versionKey: false | ||
}); | ||
|
||
export const ERC721TransactionOperation = mongoose.model("ERC721TransactionOperation", transactionOperationSchema ); |
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