Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: magic BIP-21 routing hints (#482)
- Loading branch information
1 parent
a4180b9
commit d82bc20
Showing
21 changed files
with
715 additions
and
47 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
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,40 @@ | ||
import { DataTypes, Model, Sequelize } from 'sequelize'; | ||
import ReverseSwap from './ReverseSwap'; | ||
|
||
type ReverseRoutingHintsType = { | ||
swapId: string; | ||
bip21: string; | ||
signature: string; | ||
}; | ||
|
||
class ReverseRoutingHint extends Model { | ||
public swapId!: string; | ||
|
||
public bip21!: string; | ||
public signature!: string; | ||
|
||
public static load = (sequelize: Sequelize) => { | ||
ReverseRoutingHint.init( | ||
{ | ||
swapId: { | ||
type: new DataTypes.STRING(255), | ||
primaryKey: true, | ||
allowNull: false, | ||
}, | ||
bip21: { type: new DataTypes.STRING(255), allowNull: false }, | ||
signature: { type: new DataTypes.STRING(255), allowNull: false }, | ||
}, | ||
{ | ||
sequelize, | ||
tableName: 'reverseRoutingHints', | ||
}, | ||
); | ||
|
||
ReverseRoutingHint.belongsTo(ReverseSwap, { | ||
foreignKey: 'swapId', | ||
}); | ||
}; | ||
} | ||
|
||
export default ReverseRoutingHint; | ||
export { ReverseRoutingHintsType }; |
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,17 @@ | ||
import ReverseRoutingHint, { | ||
ReverseRoutingHintsType, | ||
} from '../models/ReverseRoutingHint'; | ||
|
||
class ReverseRoutingHintRepository { | ||
public static addHint = (hints: ReverseRoutingHintsType) => | ||
ReverseRoutingHint.create(hints); | ||
|
||
public static getHint = (swapId: string) => | ||
ReverseRoutingHint.findOne({ | ||
where: { | ||
swapId, | ||
}, | ||
}); | ||
} | ||
|
||
export default ReverseRoutingHintRepository; |
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
Oops, something went wrong.